Handling itemclick event on tree panel Extjs 4

前端 未结 3 1851
猫巷女王i
猫巷女王i 2020-12-29 14:55

what I am trying to do is to get different reaction on a different tree LEAF click!

var myTree = Ext.create(\'Ext.tree.Panel\',
    store: store,
    rootVis         


        
3条回答
  •  北海茫月
    2020-12-29 15:17

    The itemclick event listener's function param "index" does not point to your tree node's index. Like you mentioned in end of your question the syntax for the itemclick event is:

    function(Ext.view.View this, Ext.data.Model record, HTMLElement item, Number index, Ext.EventObject e) {
    
    }
    

    Here is an example:

    itemclick : function(view,rec,item,index,eventObj) {
    
        // You can access your node information using the record object
        // For example: record.get('id') or record.get('some-param')
        if(r.get('id')=='SP') {
            // I do my necessary logic here.. may be open a perticular window, grid etc..
        }
    
        if(r.get('id')=='CO') {
            // I do my necessary logic here.. may be open a perticular window, grid etc..
        }           
    }
    

    And here is an example of my tree node's data:

    { text: 'SP Reports', id: 'SP', leaf: true},
    { text: 'CO Reports', id: 'CO', leaf: true},
    

提交回复
热议问题