EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jega on August 14, 2021, 11:34:48 AM



Title: [SOLVED] Tree empty node
Post by: jega on August 14, 2021, 11:34:48 AM
Hi.

Trying to load data from a file system, to show folders and files. Problem is showing an empty folder.

ID 111 is a folder, with no files. This folder repeats all tree nodes from toplevel. I need to show this folder exists, but with no files

[{
   "id": 1,
   "text": "Top level folder",
   "state": "open",
   "children": [{
      "id": 11,
      "text": "Sub folder 11",
      "state": "closed",
      "children": [{
         "id": 111,
         "text": "Empty Sub folder to id 11",
         "state": "closed"
      }]
   },{
      "id": 12,
      "text": "Sub folder 12",
      "state": "closed",
      "children": [{
         "id": 121,
         "text": "Sub folder to id 12",
         "state": "closed",
         "children":[{
            "id": 1211,
            "text": "File in sub folder 121"   
         }]
      }]   
   }]
}]


Title: Re: Tree empty node
Post by: jarry on August 15, 2021, 07:07:09 AM
An empty node shouldn't has the 'closed' state. You can set it to a file node with the folder icon. Please refer to the code below.

Code:
<style type="text/css">
.node-empty{
background: url('https://www.jeasyui.com/easyui/themes/default/images/tree_icons.png') no-repeat -208px 0;

}
</style>
Code:
   "children": [{
      "id": 11,
      "text": "Sub folder 11",
      "state": "closed",
      "children": [{
         "id": 111,
         "text": "Empty Sub folder to id 11",
         "state": "open",
         "iconCls": "node-empty"
      }]
   },{


Title: [SOLVED] Re: Tree empty node
Post by: jega on August 15, 2021, 07:21:18 AM
Thanks

Works as expected.

Jesper