Results 1 to 8 of 8

Thread: How to get checked nodes from TreePanel?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Mar 2010
    Location
    Moscow, Russia
    Posts
    24

    Default How to get checked nodes from TreePanel?

    Where is treepanel.getChecked() in Ext4???

  2. #2
    Sencha User
    Join Date
    Mar 2010
    Location
    Moscow, Russia
    Posts
    24

    Default

    It seems there are a lot of things are absent in docs, and some old functions are missed even in code

    Here is getChecked for TreePanel

    Code:
    Ext.override(Ext.tree.TreePanel,{
        getChecked: function( prop ){
            var prop = prop || null;
            var checked = [];
    
            this.getView().getTreeStore().getRootNode().cascadeBy(function(node){
               if( node.data.checked ){
                    if( prop && node.data[prop] ) checked.push(node.data[prop]);
                    else checked.push(node);
               }
            });
    
            return checked;
        }
    });
    And how to use it

    Code:
    // to get array of nodes
    var checked_nodes = treepanel.getChecked();
    
    // to get array of ids of checked nodes
    var checked_ids = treepanel.getChecked('id');

  3. #3
    Ext JS Premium Member sebsei's Avatar
    Join Date
    May 2007
    Location
    Copenhagen, Denmark
    Posts
    69

    Default

    This is a little easier, and the way it's meant to be:

    Code:
    treepanel.view.getSelectionModel().getSelection();
    The TreePanel's view has a method called getSelectionModel(), which will return an instance of Ext.selection.TreeModel (i guess, it's not in the docs yet), which is a subclass of Ext.selection.Model (http://dev.sencha.com/deploy/ext-4.0...ion.Model.html)

    Edit: But I agree that it's a little heavier than Ext 3.x style.

  4. #4
    Sencha User
    Join Date
    Mar 2010
    Location
    Moscow, Russia
    Posts
    24

    Default

    sebsei,

    the way you mentioned returns selected nodes (like rows in grid), but not checked (with checkboxes)

  5. #5
    Sencha Premium Member steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,676

    Default

    don't forget to post it in the bug forum
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  6. #6
    Ext JS Premium Member sebsei's Avatar
    Join Date
    May 2007
    Location
    Copenhagen, Denmark
    Posts
    69

    Default

    @nee, you are right. In the source code a method called getChecked is implemented on Ext.tree.TreeView, but it's empty.

    @steffen, done: http://www.sencha.com/forum/showthre...701#post589701

Similar Threads

  1. Checkbox Tree Child nodes not checked When parent checked
    By mgarn in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 6 Jan 2012, 8:33 AM
  2. Help In Getting the Nodes Checked in for the tree Panel.
    By er.viveksharma in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 1 Apr 2011, 10:53 AM
  3. Filtering the checked nodes in a Tree Panel
    By parit in forum Ext GWT: Discussion
    Replies: 0
    Last Post: 10 Jun 2010, 7:44 AM
  4. Tree.TreePanel: how can i checked nodes recursively ?
    By mikeschthecat in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 2 Nov 2009, 1:07 PM
  5. [AsyncTreenode] have checked nodes auto expanded?
    By extjsF4n in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 3 Jun 2008, 11:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •