EasyUI Forum

General Category => General Discussion => Topic started by: catpaw on January 31, 2017, 07:21:17 PM



Title: [SOLVED] treegrid get current id changes
Post by: catpaw on January 31, 2017, 07:21:17 PM
hello, Im using treegrid edit mode like http://www.jeasyui.com/demo/main/?plugin=TreeGrid&theme=default&dir=ltr&pitem=

(Editable TreeGrid)

but in the save function of the demo,
only showed how end editing row, and I have not been able to find the method to get the data just changed

I readed the forum and saw a post where used find method, but this get all rows, not the current row I just changed

this my code so far

Code:
function save(){
if (editingId != undefined){
var t = $('#tg-areas');
t.treegrid('endEdit', editingId);

//send data & save to db
var row = t.treegrid('find',editingId);
alert(JSON.stringify(row)); --> this print all rows data

editingId = undefined;
}
}

some help please, thaks


Title: Re: treegrid get current id changes
Post by: stworthy on February 01, 2017, 06:51:15 AM
Please listen to the 'onAfterEdit' event, retrieve the current saved row and post to server.
Code:
$('#tg').treegrid({
onAfterEdit: function(row){
//post to server
}
});


Title: Re: treegrid get current id changes
Post by: catpaw on February 01, 2017, 09:12:24 AM
hi stworthy

I did what you said, but Im still get all rows not just what I have changed

Code:
$('#tg-areas').treegrid({
onAfterEdit: function(row){
alert(JSON.stringify(row));
}
});

I dont understand why this hapens


other question how I determinated with onAfterEdit event if have changes or was canceled???


Title: Re: treegrid get current id changes
Post by: catpaw on February 01, 2017, 11:01:11 AM
I just realized that

Quote
I did what you said, but Im still get all rows not just what I have changed

Code:
$('#tg-areas').treegrid({
   onAfterEdit: function(row){
      alert(JSON.stringify(row));
   }
});

not returned all rows, return the row changed and his childrens

so the question is, how I get the only the row data I changed?

thanks

---------------- Edit

hi again, I understand now, not returned all rows, it return the childrens as subarray

thanks I think the issue is resolved