Title: The datagrid updateRow and getChanges problem.
Post by: frankgao 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"); 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', } }); }
Title: Re: The datagrid updateRow and getChanges problem.
Post by: stworthy on November 04, 2015, 06:02:29 PM
Please try to override the 'updateRow' method. (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);
|