EasyUI Forum
May 15, 2024, 09:51:16 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: treegrid Jquery: folder is converted to file after all children are removed.  (Read 3932 times)
vladj
Newbie
*
Posts: 5


View Profile
« on: August 23, 2018, 06:00:10 AM »

Hi!

I am writing an app presenting some tree-like structure, similar to file structure on disk. I found that after last child is removed folder icon is replaced by file. This is not how file system behaves - even if you remove all files folder stays folder. Similarly replacing the folder by file is not the desired behavior for my app.

Looking at the code of jquery.ui.min.js I see that this is done intentionally. Here is a snippet inside of DeleteRow:

   var _a15 = del(id);
   if (_a15) {
         if (_a15.children.length == 0) {
         tr = opts.finder.getTr(_a14, _a15[opts.idField]);
         tr.next("tr.treegrid-tr-tree").remove();
         var cell = tr.children("td[field=\"" + opts.treeField + "\"]").children("div.datagrid-cell");
         cell.find(".tree-icon").removeClass("tree-folder").addClass("tree-file");
         cell.find(".tree-hit").remove();
         $("<span class=\"tree-indent\"></span>").prependTo(cell);
      }
   }

So my question is: besides just commenting out this code - which I would hate to do - can you propose some more legitimate way of achieving what I want to achieve? Something with prototyping?

Thanks!
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: August 23, 2018, 05:18:47 PM »

The 'tree-file' indicate if the node is a leaf node. If no child nodes exist, it acts as a leaf node. If you want to make a leaf node become a folder, please add a customer icon class to this node.
Code:
{
  "id":21,
  "name":"Java",
  "size":"",
  "date":"01/13/2010",
  "state":"closed",
  "iconCls":"myfolder",
}

And then define this 'myfolder' style.
Code:
<style type="text/css">
  .myfolder.tree-file{
    background-position: -208px 0;
  }
</style>
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!