Looks like we cannot reproduce this. Please provide another test case to reproduce this issue.
  1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    11
    Vote Rating
    0
    shav is on a distinguished road

      0  

    Default Ext.tree.Panel node doesn't keep the selection when iconCLs is changed

    Hi All.
    I'm using ExtJS4 treepanel and I'm getting such a problem:
    when user clicks on a tree node it's icon should be changed. When I try to change the iconCls property, node's selection disappears.

    Code:
    Ext.onReady(function() {
        var store = Ext.create('Ext.data.TreeStore', {
            root: {
                text: 'Root',
                expanded: true,
                children: [
                { text: "detention", leaf: true, opened: false },
                { text: "homework", expanded: true, opened: false, children: [
                    { text: "book report", leaf: true, opened: false },
                    { text: "alegrbra", leaf: true, opened: false}
                ] },
                { text: "buy lottery tickets", leaf: true, opened: false }
                ]
            }
        });
    
        var tree = Ext.create('Ext.tree.Panel', {
    store: store,
            width: 250,
            height: 300,
            renderTo: document.body,
            listeners: {
                itemclick: function(view) {
                    var selectedNode = view.getSelectionModel().getSelection()[0];
                    var icon = '';
                    if (selectedNode.data.opened === true) {
                        icon = 'folder-closed-16';
                        selectedNode.set('opened', false);
                    }
                    else {
                        icon = 'folder-opened-16';
                        selectedNode.set('opened', true);
                    }
                    selectedNode.set('iconCls', 'x-tree-node-icon ' + icon);
                }
            }
        });
        
    });
    Note, that if I remove the call to selectedNode.set(), selection is kept but the iconCls is not changed.

    Is there any workaround/fix for this? Is it an Ext bug or am I doing something wrong?
    Thank You.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    38,488
    Vote Rating
    1112
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default

    This was fixed in 4.1.2 and is also in the newly released 4.2.0 GA
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1