EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Sapphire on May 08, 2014, 11:22:55 PM



Title: TreeGrid: empty folder icon
Post by: Sapphire on May 08, 2014, 11:22:55 PM
Hello together,

based on the Lazy loading nodes in TreeGrid example (http://www.jeasyui.com/tutorial/tree/treegrid5.php) i have question about node with an empty children list.

I have modified the data set for this example and add a node with an empty children list on the end

{
   "id":99,
   "name":"D",
   "size":"",
   "date":"02/19/2010",
   "children":[
   ]   
}

In the a attached picture (empty_folder1.jpg) you can see a folder icon for D.

If i remove the lazy load functionality by removing the loadFilter data-option from the html file i got this result (empty_folder2.jpg)

The you can see a file icon for D.

How i can defined which icon is display for a node with a children list without members (empty folder).


Title: Re: TreeGrid: empty folder icon
Post by: stworthy on May 09, 2014, 12:40:04 AM
Override the 'setData' function as below and they will have the same behavior.
Code:
function setData(data){
var todo = [];
for(var i=0; i<data.length; i++){
todo.push(data[i]);
}
while(todo.length){
var node = todo.shift();
if (node.children && node.children.length){
node.state = 'closed';
node.children1 = node.children;
node.children = undefined;
todo = todo.concat(node.children1);
}
}
}