EasyUI Forum
September 14, 2025, 02:57:34 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [SOLVED] Tree empty node  (Read 6289 times)
jega
Full Member
***
Posts: 225


View Profile
« 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"   
         }]
      }]   
   }]
}]
« Last Edit: August 15, 2021, 07:22:04 AM by jega » Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #1 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"
      }]
   },{
Logged
jega
Full Member
***
Posts: 225


View Profile
« Reply #2 on: August 15, 2021, 07:21:18 AM »

Thanks

Works as expected.

Jesper
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!