View Full Version : Search on treepanel
hieu79vn
17 Jun 2012, 1:33 PM
Hi,
I have a tree with a textbox above. I want to search for the node by typing in the text box. If a part of nodes' name match the text, the nodes' text will be highlighted. Does TreePanel support this function?
Thank you
hieu79vn
17 Jun 2012, 1:53 PM
it looks like this but for a treepanel
http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/grid/live-search-grid.html
scottmartin
18 Jun 2012, 9:58 AM
I believe you will have to RYO to get this functionality ... you would have to iterate through all your nodes and expand the parent nodes that contain a match for highlight.
Scott.
hieu79vn
18 Jun 2012, 11:19 PM
Thank you Scott,
Do you have a sampe code, please?
redraid
19 Jun 2012, 3:18 AM
What we need:
(http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.NodeInterface-method-eachChild)http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.NodeInterface-method-eachChild
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.NodeInterface-method-getPath
(http://docs.sencha.com/ext-js/4-1/#!/api/Ext.tree.Panel-method-expandPath)http://docs.sencha.com/ext-js/4-1/#!/api/Ext.tree.Panel-method-expandPath
Example:
var root = tree.getRootNode(),
node = false;
root.eachChild(function (n) {
if (....) {
node = n;
return false;
}
});
if (node) {
// expand node
tree.expandPath(node.getPath());
}
//wbr
hieu79vn
20 Jun 2012, 12:02 AM
Thank you. I will try it
Powered by vBulletin® Version 4.2.3 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.