jquery-treetable icon indicating copy to clipboard operation
jquery-treetable copied to clipboard

removeNode on last child node does not remove the arrow from the parent

Open dorner opened this issue 9 years ago • 4 comments

If I call $('#my-table').treetable('removeNode', '45'); where 45 is the last remaining child of a parent, that parent will still show the down arrow after the node is removed. The arrow should disappear since there are no more children.

dorner avatar Oct 20 '14 20:10 dorner

Wow, this is bad. How do I even fix this manually?

mvasilkov avatar Jan 29 '15 11:01 mvasilkov

    $('#root-category-table').treetable('removeNode', id);
    var parent = $('#root-category-table').treetable('node', parentID);
    // workaround for https://github.com/ludo/jquery-treetable/issues/157
    if (parent.children.length == 0) {
      parent.row.find('.indenter').html('');
    }

dorner avatar Jan 30 '15 14:01 dorner

Thanks @dorner! I ended up doing something very similar here: https://github.com/Infinidat/jquery-treetable/commit/8a6d49102f63e6a559325e5d8aa3f0c74422204c

The reason for deleted is, sometimes we're just collapsing the tree, so the arrows should stay intact.

mvasilkov avatar Jan 30 '15 14:01 mvasilkov

I have issue while initializing the tree data. On initializing, parent sub-nodes check is not working. parentDom.parent().find(".class-level").length always gives me length 0 even if it is a parent node

this is the code I wrote on initialize: settings.onInitialized(function (_data) { settings.selectData = _data.TaskTypes; var data = _data.ProjectTasks; for (var i = 0; i < data.length; i++) { var row = { id: data[i].Id, level: data[i].Level, pid: data[i].PId, name: data[i].Name, taskType: data[i].TaskType, startDate: data[i].StartDate, endDate: data[i].EndDate }; var treenode=generateTreeNode(dom_table, row, row.level); treeData[row.id] = row; var expendIcon = dom_table.find("li.j-expend"); if (expendIcon.parent().attr("data-loaded")) { //toggleicon($(expendIcon)); //toggleExpendStatus(expendIcon, treenode); } } settings.bindDropDown(); });

Please suggest

RG2712 avatar Mar 29 '18 06:03 RG2712