EasyUI Forum
May 05, 2024, 09:42:17 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: bug in tree  (Read 10024 times)
A-K
Full Member
***
Posts: 122


View Profile WWW
« on: December 13, 2014, 05:47:40 AM »

Hey,
I found a problem in the tree, When using loader in the tree everything works great.
It will first call the "onBeforeLoad" and only then it will call the "onLoadSuccess".

But when using data instead of loader it will first call the "onLoadSuccess" and only then the "onBeforeLoad" which is clearly a problem.

Using loader: http://jsfiddle.net/9kfg5y02/3/

Using data: http://jsfiddle.net/9kfg5y02/4/

Any fix for this would really help, Thanks!
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: December 13, 2014, 07:19:02 AM »

When a tree is created, it will load the locale data first(if the 'data' property is assigned) and then try to load remote data.
In the second example, the 'data' property is assigned, so the 'onLoadSuccess' event fires. Finally, the tree will try to load remote data, the 'onBeforeLoad' event fires but the 'onLoadSuccess' event does not fire again since the 'url' property is not assigned.
Logged
A-K
Full Member
***
Posts: 122


View Profile WWW
« Reply #2 on: December 13, 2014, 07:58:24 AM »

I understand what you are saying but it is making it more complicated to work with the tree,
can it call onBeforeLoad for local data?
and can it not call onBeforeLoad again when no remote data was assigned?

I am using a tree as an infrastructure for my team and I would need to check
every time if they used data or loader for using onLoadSuccess and onBeforeLoad correctly..

Thanks.
« Last Edit: December 13, 2014, 08:08:07 AM by A-K » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 on: December 14, 2014, 04:45:12 AM »

Loading locale data does not trigger the onBeforeLoad event. This event fires only when a request is made to load remote data.
Logged
A-K
Full Member
***
Posts: 122


View Profile WWW
« Reply #4 on: December 14, 2014, 09:30:21 AM »

I cant understand why.. I have a code that I want to run before loading any data to the tree(doesnt matter if its from the server or local),
this is the only place I can do it before the data is loaded as an infrastructure.
but anyway, thanks.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #5 on: December 14, 2014, 05:33:55 PM »

You can try to use the 'loadFilter' function, which will be called before loading data to the tree.
Code:
$('#tt').tree({
loadFilter:function(data){
var opts = $(this).tree('options');
if (opts.data){
console.log('load local data')
}
if (opts.url){
console.log('load remote data')
}
return data;
}
})
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!