Skip to content

Commit

Permalink
DataGrid: Call saveEditData manually after set cellValue (T661354) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
komarovalexander committed Aug 22, 2018
1 parent 1e8d285 commit 2ba8f52
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
4 changes: 2 additions & 2 deletions js/ui/grid_core/ui.grid_core.editing.js
Original file line number Diff line number Diff line change
Expand Up @@ -1411,10 +1411,10 @@ var EditingController = modules.ViewController.inherit((function() {
that._addEditData(params, options.row);
that._updateEditButtons();

if(options.column.showEditorAlways) {
if(options.column.showEditorAlways && !forceUpdateRow) {
if(editMode === EDIT_MODE_CELL && options.row && !options.row.inserted) {
return that.saveEditData();
} else if(editMode === EDIT_MODE_BATCH && !forceUpdateRow) {
} else if(editMode === EDIT_MODE_BATCH) {
columns = that._columnsController.getVisibleColumns();
forceUpdateRow = columns.some((column) => column.calculateCellValue !== column.defaultCalculateCellValue);
}
Expand Down
31 changes: 30 additions & 1 deletion testing/tests/DevExpress.ui.widgets.dataGrid/editing.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5842,7 +5842,9 @@ QUnit.test("repaintRows should be skipped on saving", function(assert) {
});

// act
this.cellValue(0, "selected", true);
var checkboxInstance = testElement.find(".dx-checkbox").eq(0).dxCheckBox("instance");
checkboxInstance.option("value", true);
this.saveEditData();
this.repaintRows([0]);

// assert
Expand All @@ -5855,6 +5857,33 @@ QUnit.test("repaintRows should be skipped on saving", function(assert) {
assert.strictEqual(changeCount, 1, "data is changed once");
});

// T661354
QUnit.test("saveEditData is not called automatically after call cellValue", function(assert) {
var testElement = $('#container'),
onRowUpdatingSpy = sinon.spy();

this.options.editing = {
allowUpdating: true,
mode: 'cell'
};

this.options.onRowUpdating = onRowUpdatingSpy;

this.columns.push({ dataField: "selected", dataType: "boolean" });

this.columnsController.init();

this.rowsView.render(testElement);
this.editingController.optionChanged({ name: "onRowUpdating" });

this.cellValue(0, "selected", true);
this.cellValue(1, "selected", true);
assert.strictEqual(onRowUpdatingSpy.callCount, 0);

this.saveEditData();
assert.strictEqual(onRowUpdatingSpy.callCount, 2);
});

// T607746
QUnit.test("The cellValue method should work correctly with visible index", function(assert) {
// arrange
Expand Down

0 comments on commit 2ba8f52

Please sign in to comment.