EasyUI
Home
Demo
Tutorial
Documentation
Download
Extension
Contact
Forum
EasyUI Forum
April 28, 2024, 07:00:54 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
:
Home
Help
Search
Login
Register
EasyUI Forum
>
General Category
>
Bug Report
>
bug fixes in treegrid remove
Pages: [
1
]
« previous
next »
Print
Author
Topic: bug fixes in treegrid remove (Read 14767 times)
asher
Newbie
Posts: 1
bug fixes in treegrid remove
«
on:
May 23, 2012, 12:54:09 AM »
Hi,
There is a bug in jquery.treegrid.js in function remove (line 630).
After it is called, the html dom element is removed but the parent node's children array still contains the deleted node.
I fixed this bug, which is a mix-up between treeField and idField.
Additionally, in case there are no children left there was the same mix-up, and also the sub-tree of the parent was not removed.
So, here are my fixes:
/**
* remove the specified node
*/
function remove(target, idValue){
var opts = $.data(target, 'treegrid').options;
var tr = opts.finder.getTr(target, idValue);
tr.next('tr.treegrid-tr-tree').remove();
tr.remove();
var pnode = del(idValue);
if (pnode){
if (pnode.children.length == 0){
//fix - start
//tr = opts.finder.getTr(target, pnode[opts.treeField]);
tr = opts.finder.getTr(target, pnode[opts.
idField
]);
tr.next('tr.treegrid-tr-tree').remove();
//fix - end
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);
}
}
setRowNumbers(target);
/**
* delete the specified node, return its parent node
*/
function del(id){
var cc;
var pnode = getParent(target, idValue);
if (pnode){
cc = pnode.children;
} else {
cc = $(target).treegrid('getData');
}
for(var i=0; i<cc.length; i++){
//fix - start
//if (cc
[opts.treeField] == id){
if (cc
[opts.
idField
] == id){
//fix - end
cc.splice(i, 1);
break;
}
}
return pnode;
}
}
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> News
=> General Discussion
=> EasyUI for jQuery
=> EasyUI for Angular
=> EasyUI for Vue
=> EasyUI for React
=> Bug Report
Loading...