How to uncheck all tree nodes in Ext.tree.TreePanel?

I would like to use the reset method to delete all checked nodes in Ext.tree.TreePanel.

+3
source share
4 answers
tree.getRootNode().cascade(function(n) {
    var ui = n.getUI();
    ui.toggleCheck(false);
});

How to find here: http://www.sencha.com/forum/showthread.php?12888-solved-programatically-unchecking-checked-tree-nodes&p=62845#post62845

+7
source

I found the method as shown below, but it seems that the "casecade" method does not work well, I need to call "reset" several times to uncheck the boxes with the marked children:

reset: function (){
            startNode = this.root;
            var f = function () {
                if (this.attributes.checked) {
                    this.attributes.checked = false;
                    this.getUI().toggleCheck(false);
                }
            };
            startNode.cascade(f);
        }
+2
source

Extjs 4.0.7. , "" , . "cascadeBy". , ( , , ).

, :

{ 
    xtype: 'button', 
    text: 'Deselect All',
    listeners:{
        click: function(){

            var tree = Ext.ComponentQuery.query( 'treepanel[itemId=user_flags_tree]')[0];
            tree.getRootNode().cascadeBy(function(){

                this.set( 'checked', false );

            });

        }
    }
}

: http://www.sencha.com/forum/showthread.php?149627-Programmaticaly-check-uncheck-checkboxes-in-the-Tree-panel

+2
var nodes = treePanel.getView().getNodes();
var records = treePanel.getView().getRecords(nodes);
for (var i = 0; i < records.length; i++) {
    records[i].set('checked',true);
}
0

Source: https://habr.com/ru/post/1780434/


All Articles