Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
425
Deselect a node?
posted

Team,

How would I remove the selection of a node on a click off the tree or node and/or deselect it on a click onto the same already selected node?

Parents
  • 11095
    Verified Answer
    Offline posted

    Hello Mark,

    Thank you for contacting Infragistics Developer Support and your patience.

    If you want to deselect node if it is already selected:

    1. You can use the nodeClick event.  
    2. You can get the selected node by using the selectedNode method to get the currently selected node
    3. You can deselect currently selected node using deselect method.
    4. However you will notice that the node is still marked as active and you can get confused that is still selected, it is deselected. To make it as unactive you can remove ui-state-focus class from the selected node.
    5. And finally you cancel the click event so the node wont be preselected.
    nodeClick: function(evt, ui) {
    	var selectedNode = $tree.igTree("selectedNode");
    		
    	if (selectedNode.path == ui.node.path) {
    		var $selectedNodeElement = selectedNode.element;
    		$tree.igTree("deselect", $selectedNodeElement);
    		$($selectedNodeElement.context).removeClass('ui-state-focus');
    		
    		
    		return false;
    	}
    }
    

    If you have any additional questions please let me know.

    igTree-deselect-node.zip
Reply Children
No Data