EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: sipingsoft on August 18, 2012, 06:40:12 AM



Title: Load data into tree grid node.
Post by: sipingsoft on August 18, 2012, 06:40:12 AM
I need to load data for node in tree grid.
There are some similar functions such as 'reload' or 'loadData'.
I'm looking forward to using loadData.
But loadData allows me to load data for entire treegird, but not for special node.
Do you know how to load data for special node?
something like this:
$('#treegrid').treegrid('loadData', data, nodeId);
Hoping for your help.

Regards,



Title: Re: Load data into tree grid node.
Post by: stworthy on August 22, 2012, 12:18:19 AM
Calling 'loadData' method for a special node is not allowed. But the user can remove all children and then append some new nodes for that node. Here is the test code to demonstrate how to do this.
Code:
function reloadData(data){
var tg = $('#test');
var node = tg.treegrid('getSelected');
if (node){
var cc = node.children||[];
while(cc.length){
tg.treegrid('remove', cc[0]['id']);
}
tg.treegrid('append', {
parent: node.id,
data: data
});
}
}