Hi All,
I've managed to implement a pretty functional 'search' facility for any easyUI tree, and I can get it to highlight and select the appropriate node.
What I can't do is see to get the jQuery .scrollTo to work with the div, ul or anything within the tree. I should point out that this tree is in a Dialog box (although I can't see that would make any difference)
Any help or suggestions on a viable ".scrollTo' implementation would be greatly appreciated.
Cheers!
Paul
function amTreeSearch(sInput, sTree)
{
var a=$('#' + sInput).val();
var node = $('#' + sTree).tree('getRoot');
var b=$('#' + sTree).tree('getData',node.target);
var node=search(b,a);
if(node)
{
$('#' + sTree).tree('expandTo', node.target);
$('#' + sTree).tree('select', node.target)
$('#' + sTree).scrollTo(node.target);
//$('#' + sTree).scrollTo(2000); // This is just to test ... it didn't work either!
}
else
{
showWarning('icon-error','Error','Sorry, I could not find any matches');
}
}
function search(obj, name) {
var a=$('<div>' + obj["text"] + '</div>').text();
var x=a.toLowerCase().indexOf(name.toLowerCase()) != -1
if (x) {
//console.log('****FOUND IT*****');
return obj;
}
if (obj.children || obj._children) {
var ch = obj.children || obj._children;
for (var i = 0; i < ch.length; i++) {
var found = search(ch[i], name);
if (found) {
return found;
}
}
}
return false;
}