1. #1
    Sencha User
    Join Date
    Mar 2012
    Location
    Baku, Azerbaijan
    Posts
    10
    Vote Rating
    0
    Julia_Rakitina is on a distinguished road

      0  

    Default Answered: Check Tree item click event

    Answered: Check Tree item click event


    I have little problem Did not find solution yet. My user interface has Check Tree for controlling opened tabs( hide/show them oh check/uncheck). For navigation on tabs I use Check Tree itemclick in all checked tabs. But I need to check checkbox on itemclick event either. I have fired event ''checkchange", but it does not actually check node. What is the solution? Please help

    Code:
     var tree = Ext.create('Ext.tree.Panel', {
               store: store,
                rootVisible: false,
                useArrows: true,
                frame: true,
                listeners : {
                    itemclick:function(node, rec){
                        var name=rec.get('id');
                        var records = tree.getView().getChecked();
                        var name_of_tab='#'+name;
                        tree.getView().fireEvent('checkchange',rec, true);
                        names = [];
    
    
                        Ext.Array.each(records, function(rec){
                            names.push(rec.get('id'));
                        });
                        if (include(names,name)==true){
                            Ext.getCmp('main').child(name_of_tab).tab.setVisible(true);
                            Ext.getCmp('main').setActiveTab(Ext.getCmp('main').child(name_of_tab));
                        }
                    },
    
    
                    checkchange : function(rec, check){
    
    
                        console.info(check);
                        var records = tree.getView().getChecked();
                        var name=rec.get('id');
                        names = [];
    
    
                        Ext.Array.each(records, function(rec){
                            names.push(rec.get('id'));
                        });
    
    
                        var name_of_tab='#'+name;
    
    
                        if (include(names,name)==true){
                            Ext.getCmp('main').child(name_of_tab).tab.setVisible(true);
                            Ext.getCmp('main').setActiveTab(Ext.getCmp('main').child(name_of_tab));
                            var store_load = Ext.data.StoreManager.get(name);
                            console.info(name);
                            store_load.load();
                        }
                        else{
                            Ext.getCmp('main').child(name_of_tab).tab.hide();
                            if (Ext.getCmp('main').getActiveTab()==Ext.getCmp('main').child(name_of_tab)){
                                Ext.getCmp('main').setActiveTab(Ext.getCmp('main').child('#main_page'));
                            }
                        };
                    }
                }
    
    
            });

  2. Don't know of I'm understanding correctly but I think you just want to be able to click on the item to check/uncheck the checkbox.

    You can just add this line to the itemclick handler:

    Code:
    rec.set('checked',!rec.get('checked'));
    this will check/uncheck and automatically fire the necessary events.

    Here is a fiddle. I commented out a lot of not working or irrelevant code just for the example..

  3. #2
    Sencha User VDP's Avatar
    Join Date
    Feb 2012
    Location
    Boom, Belgium
    Posts
    87
    Vote Rating
    10
    Answers
    3
    VDP will become famous soon enough

      0  

    Default


    Don't know of I'm understanding correctly but I think you just want to be able to click on the item to check/uncheck the checkbox.

    You can just add this line to the itemclick handler:

    Code:
    rec.set('checked',!rec.get('checked'));
    this will check/uncheck and automatically fire the necessary events.

    Here is a fiddle. I commented out a lot of not working or irrelevant code just for the example..

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Location
    Baku, Azerbaijan
    Posts
    10
    Vote Rating
    0
    Julia_Rakitina is on a distinguished road

      0  

    Default


    Yes! Thank you so much!

  5. #4
    Sencha User
    Join Date
    May 2013
    Posts
    1
    Vote Rating
    0
    tonyhhkx is on a distinguished road

      0  

    Default Tree checkbox event click

    Tree checkbox event click


    Edit: sorry i wrong