EasyUI Forum
November 06, 2025, 03:44:11 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: Combotree empty folder icon  (Read 7829 times)
LastByte
Newbie
*
Posts: 2


View Profile
« on: October 13, 2015, 06:37:38 PM »

Trying to figure out how to display a folder tree with only 'folder' icons.  no files involved here. The idea is to choose a folder.

The default display shows a file icon for leaf nodes.

I have tried the following workaround, but the folders show up in permanently open state, whether collapsed or not.

loadFilter: function(data, parent){
   function forNodes(data, callback){
        .
        .
        }

        forNodes(data, function(node){
            node.iconCls = 'open-folder';
        });
        return data;

}



 
« Last Edit: October 14, 2015, 05:31:49 AM by LastByte » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: October 14, 2015, 08:50:29 AM »

The 'open-folder' CSS style must be defined correctly:
Code:
<style type="text/css">
.open-folder{
background: url('http://www.jeasyui.com/easyui/themes/default/images/tree_icons.png') no-repeat -224px 0;
}
</style>

You can use the 'loadFilter' function to custom all the leaf nodes:
Code:
$('#cc').combotree({
loadFilter: function(data,parent){
function forNodes(data, callback){
var nodes = [];
for(var i=0; i<data.length; i++){
nodes.push(data[i]);
}
while(nodes.length){
var node = nodes.shift();
if (callback(node) == false){return;}
if (node.children){
for(var i=node.children.length-1; i>=0; i--){
nodes.unshift(node.children[i]);
}
}
}
}
forNodes(data,function(node){
if (!node.children || !node.children.length){
node.iconCls = 'open-folder';
}
});
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!