[CLOSED] TreePanel Node Check Through Javascript

  1. #1

    [CLOSED] TreePanel Node Check Through Javascript

    Hello

    I am working with the TreePanel and trying to "uncheck" a node via javascript when a certain event happens but I cannot find a way to do it.

    I have tried the following:
    lastCheckedNode.data.checked = false;
    lastCheckedNode.raw.checked = true;
    lastCheckedNode.attributes.checked = false;

    On the CheckChange event of the TreePanel I have the following listener. When the function is called it keeps track of the last node that was checked or unchecked so that if a different node is checked it will uncheck the previous node.
    <Listeners>
      <CheckChange Handler="TreeItemChecked(item)" />
    </Listeners>
    var lastCheckedNode = null;
    function TreeItemChecked(item) {
            
            if (lastCheckedNode != null && lastCheckedNode != item) {
                // uncheck the last node that was passed into this function
                // how?
                // lastCheckedNode.checked = true;   // doesn't work
            }
            lastCheckedNode = item;
    
            // do other stuff
        }
    There is reference to a toggleCheck() method of the TreeNodeUI in the Sencha docs but it does not appear to be exposed.

    Thank you for your help.
    Last edited by Daniil; Nov 15, 2012 at 3:41 PM. Reason: [CLOSED]
  2. #2
    Hello!

    To get the last checked node you can use
    this.getSelectionModel().getLastSelected();
    To uncheck node use this code in CheckChange Handler:
    this.getSelectionModel().getLastSelected().set('checked', false);
  3. #3

    [CLOSED]TreePanel Node Check Through Javascript

    Thank you Baidaly!!!

    .set('checked', false);
    worked perfect.

    And thank you for such a quick response to my post.
    Last edited by Daniil; Nov 15, 2012 at 3:40 PM. Reason: Please use [CODE] tags

Similar Threads

  1. [CLOSED] check/uncheck for all child node in treepanel
    By majestic in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 15, 2012, 3:11 AM
  2. Replies: 0
    Last Post: Aug 09, 2012, 8:30 AM
  3. [CLOSED] Check node count after applying filterBy for TreePanel
    By bakardi in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 13, 2012, 2:29 PM
  4. Replies: 1
    Last Post: Apr 08, 2010, 6:28 PM
  5. TreePanel:Copying from one node to another node using drag and drop
    By eighty20 in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jan 25, 2009, 7:48 AM

Tags for this Thread

Posting Permissions