EasyUI Forum
May 06, 2024, 09:43:12 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: treegrid remove event  (Read 11139 times)
zhangjian420
Newbie
*
Posts: 8


View Profile
« on: December 23, 2014, 07:48:56 AM »

t.treegrid("remove",id);
         var data = t.treegrid("getData");
         console.info(data);

This is my code . After it is called, the html dom element is removed but when I invoke the  'getData' method, the result also contains the removed data。

easyui version 1.4 。 waiting.....
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: December 23, 2014, 08:46:28 AM »

The 'remove' method can remove the specified node. Please check your code carefully. If your issue continues, please provide an example to demonstrate your issue.
Logged
zhangjian420
Newbie
*
Posts: 8


View Profile
« Reply #2 on: December 24, 2014, 06:31:26 AM »

The 'remove' method can remove the specified node. Please check your code carefully. If your issue continues, please provide an example to demonstrate your issue.
Code:
function deleteSubject(id){
var t = $('#tt');
$.messager.confirm('提示', '确定删除该科目?', function(r){
if(r){
var data1 = t.treegrid("getData");
console.info(data1);
t.treegrid("remove",id);
var data = t.treegrid("getData");
console.info(data);
}
});

/*var footer = t.treegrid("getFooterRows");
var json = {};
json.total = 10;
json.rows = data;
json.footer = footer;
t.treegrid("loadData",json);*/
}
« Last Edit: December 24, 2014, 06:35:36 AM by zhangjian420 » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: December 24, 2014, 07:04:15 AM »

Please confirm if you removed the node successfully. Here is the example http://jsfiddle.net/mgq8h4d2/. It works fine.
Logged
zhangjian420
Newbie
*
Posts: 8


View Profile
« Reply #4 on: December 24, 2014, 07:38:07 AM »

Please confirm if you removed the node successfully. Here is the example http://jsfiddle.net/mgq8h4d2/. It works fine.

Hello , The attachment is my example。
wait on line....

In my demo,when i delete the first node then it works fine. but when i delete the other nodes ,it doesn't work
« Last Edit: December 24, 2014, 07:52:17 AM by zhangjian420 » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: December 24, 2014, 09:08:27 PM »

Your json data has the wrong format, please use the 'loadFilter' function to convert your original data to correct data format.
Code:
$('#tt').treegrid({
loadFilter:function(data,parentId){
function getRows(children){
var rows = [];
function setRows(pid, children){
$.map(children, function(row){
row._parentId = pid;
rows.push(row);
if (row.children && row.children.length){
setRows(row.id, row.children);
}
row.children = undefined;
});
}
setRows(null, children);
return rows;
}
data.rows = getRows(data.rows);
return data;
}
})
Logged
zhangjian420
Newbie
*
Posts: 8


View Profile
« Reply #6 on: December 26, 2014, 05:47:34 AM »

Your json data has the wrong format, please use the 'loadFilter' function to convert your original data to correct data format.
Code:
$('#tt').treegrid({
loadFilter:function(data,parentId){
function getRows(children){
var rows = [];
function setRows(pid, children){
$.map(children, function(row){
row._parentId = pid;
rows.push(row);
if (row.children && row.children.length){
setRows(row.id, row.children);
}
row.children = undefined;
});
}
setRows(null, children);
return rows;
}
data.rows = getRows(data.rows);
return data;
}
})

thank you very much!
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!