EasyUI Forum
May 17, 2024, 02:42:23 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: The datagrid updateRow and getChanges problem.  (Read 9191 times)
frankgao
Jr. Member
**
Posts: 53


View Profile Email
« on: November 03, 2015, 01:03:51 AM »

Hi,Master.

I need to change the cell value when I double click the datagrid row,but if i call the getChanges method after this,I don't see the cell modified by program in the list.
I had search the question by google,but none answer about this.
Can anybody tell me how can I fix this?
Thanks


var updated = $('#griddetail').datagrid('getChanges', "updated");

Code:
       columns: [[
                { field: 'wfd_id', hidden: true, title: 'ID' },
                { field: 'emname_st', title: 'Name', width: '80px' },
                { field: 'deptname', title: 'Department', width: '80px' },
                { field: 'condition1', title: 'Condition1', width: '100px', editor: { type: 'text', options: { required: true } } },
                { field: 'condition2', title: 'Condition2', width: '100px', editor: { type: 'text', options: { required: true } } }
            ]],
            onDblClickRow: function (rowIndex, rowData) {
                doeditRow(rowIndex, rowData);
            }


    function doeditRow(rowIndex, rowData) {
        $('#griddetail').datagrid('selectRow', editIndex)
        .datagrid('beginEdit', editIndex);
        $('#griddetail').datagrid('updateRow', {
            index: editIndex,
            row: {
                condition1:'1',
                deptname: 'New Name',
            }
        });
    }

« Last Edit: November 03, 2015, 11:32:44 PM by frankgao » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: November 04, 2015, 06:02:29 PM »

Please try to override the 'updateRow' method.
Code:
(function($){
$.extend($.fn.datagrid.methods, {
updateRow: function(jq, param){
return jq.each(function(){
var target = this;
var state = $.data(target, 'datagrid');
var opts = state.options;
var row = opts.finder.getRow(target, param.index);
var updated = false;
for(var field in param.row){
if (row[field] != param.row[field]){
updated = true;
break;
}
}
if (updated){
if ($.inArray(row, state.insertedRows) == -1){
if ($.inArray(row, state.updatedRows) == -1){
state.updatedRows.push(row);
}
}
$.extend(row, param.row);
opts.view.updateRow.call(opts.view, this, param.index, param.row);
}
});
}
})
})(jQuery);
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!