开发者

ExtJS Find Node within Tree Branch

开发者 https://www.devze.com 2023-01-18 19:31 出处:网络
I\'m trying to check whether a certain node exists beneath a branch of an ExtJS tree. Knowing the ID of the parent node, is 开发者_JAVA技巧there a library function to check whether a node exists benea

I'm trying to check whether a certain node exists beneath a branch of an ExtJS tree. Knowing the ID of the parent node, is 开发者_JAVA技巧there a library function to check whether a node exists beneath the parent (by its ID)?

I've checked the API numerous times over, and can only seem to accomplish this by iterating through the entire branch of the tree.

Is there a library function which allows me to check if a child exists (by its ID) if the parent node ID is known?

Thanks!

PS, to find the parent ID, I'm using the following:

tree.getNodeById('myID');


Ext.tree.TreeNode "contains" function does exactly what you want:

var parent = tree.getNodeById('myID');
parent.contains(tree.getNodeById('childId'));


Have you looked at DomQuery? The API defines the method jsSelect: selects a group of elements.

jsSelect( String selector, [Node/String root] ) : Array

Parameters:

selector : String The selector/xpath query (can be a comma separated list of selectors) root : Node/String (optional) The start of the query (defaults to document).

Returns an Array of DOM elements which match the selector. If there are no matches, and empty Array is returned.

0

精彩评论

暂无评论...
验证码 换一张
取 消