EasyUI Forum
May 15, 2024, 02:56:26 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Tree search and Scroll to  (Read 10076 times)
PaulMcGuinness
Newbie
*
Posts: 15


View Profile Email
« on: July 08, 2013, 08:40:15 AM »

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

Code:

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;
}
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 09, 2013, 01:21:54 AM »

If you want to scroll the tree, please try the code below:
Code:
var p = $('#' + sTree).parent();  // the parent container
p.scrollTop(200);
Logged
PaulMcGuinness
Newbie
*
Posts: 15


View Profile Email
« Reply #2 on: July 09, 2013, 03:02:44 AM »

Nope... doesn't work. Is it because it is within a Dialog do you think?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!