jquery-treetable
jquery-treetable copied to clipboard
removeNode on last child node does not remove the arrow from the parent
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.
Wow, this is bad. How do I even fix this manually?
$('#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('');
}
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.
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