EasyUI Forum
September 16, 2025, 08:56:47 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: cant get changed rows from datagrid [solved]  (Read 14121 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: February 27, 2013, 09:09:08 PM »

This always returns 0 even though changes have been made to the rows.

Code:
var dg = $(this).datagrid('acceptChanges');
$(this).datagrid('endEdit');
var rows = $(this).datagrid('getChanges');
cl(rows.length);

The datagrid mode changes correctly after the acceptChanges(), however the getChanges() never seems to work.
« Last Edit: March 01, 2013, 03:07:08 AM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 27, 2013, 11:15:02 PM »

The 'acceptChanges' method commit all the changed data and 'getChanges' method return changed rows since the last commit. Calling 'getChanges' after 'acceptChanges' will return no rows. To get the changed rows, try the following code:
Code:
//var dg = $(this).datagrid('acceptChanges');
$(this).datagrid('endEdit');
var rows = $(this).datagrid('getChanges');
cl(rows.length);
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #2 on: February 27, 2013, 11:59:05 PM »

Thanks, I tried that, still no records returned:
Code:
// Is this a Datagrid ??
$frm.find("table").each(function(){
if(this.id) {
//var dg = $(this).datagrid('acceptChanges');
$(this).datagrid('endEdit');
console.log($(this).datagrid('getChanges'));
}
});
Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: February 28, 2013, 01:21:06 AM »

Here is the row editing example http://www.jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=default&dir=ltr&pitem=Row%20Editing%20DataGrid.

Edit some rows and then click the 'GetChanges' button. It will tell you the changed rows count.
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #4 on: February 28, 2013, 02:34:17 AM »

Thanks, I did that it does work when you select another row after editing the first, but not when you tab between the columns on the same row.

But what are the specific datagrid events that need to happen for the getChanged() function to work ??

1) selectRow()
2) beginEdit()
3) endEdit()
4) getChanged()

This is what I am doing now, I suspect there is a step missing ??

Many Thanks
Logged

-- Licensed User --
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #5 on: February 28, 2013, 02:58:31 AM »

OK, I have figured it out, you have to endEditing on each row, you cannot just endEditing for the whole datagrid.

This won't work:
Code:
$(this).datagrid('endEdit');

This does work:
Code:
$(this).datagrid('endEdit',editIndex);

Thanks again.
Logged

-- Licensed User --
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!