EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: erkin on July 12, 2017, 12:32:58 AM



Title: Datagrid editing
Post by: erkin on July 12, 2017, 12:32:58 AM
Hello!
I have in a datagrid the one complex field as key-value object. To edit this field, I made an custom editor in modal dialog.
How to make so that after editing this datagrid row was marked as updated and was in the result returned by datagrid('getChanges', 'updated')?


Title: Re: Datagrid editing
Post by: Pierre on July 12, 2017, 01:20:50 AM
To update row:
You need to have defined "idField" in your datagrid (check doc's how to do that).
Then you have something like this:
Code:
  var yourID = $('#dg').datagrid('getSelected').id;          // get selected ID
  var index = $('#dg').datagrid('getRowIndex',yourID);       // get index
  $('#dg').datagrid('updateRow',{
    index: index,
    row: {
      yourfield1: 'some field from your dialog (editor)',
      yourfield2: 'some other value'
    }
  });

to get changes, here is example: http://www.jeasyui.com/easyui/demo/datagrid/rowediting.html


Title: Re: Datagrid editing
Post by: erkin on July 12, 2017, 04:14:17 AM
Thank for answer and example code, it work!
I incorrectly called UpdateRow and getChanges did not return anything.