Skip to content

Commit

Permalink
DataGrid: Fix row deleting if boolean column and validation exist and…
Browse files Browse the repository at this point in the history
… editing mode is row (T865833) (#12146)
  • Loading branch information
vconst authored Feb 27, 2020
1 parent 6c6d4a6 commit caa1a6b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/ui/grid_core/ui.grid_core.editing.js
Original file line number Diff line number Diff line change
Expand Up @@ -1308,12 +1308,12 @@ const EditingController = modules.ViewController.inherit((function() {
const dataController = this._dataController;
const item = dataController.items()[rowIndex];
const key = item && item.key;
const editIndex = getIndexByKey(key, this._editData);
const oldEditRowIndex = this._getVisibleEditRowIndex();
const isBatchMode = this.option('editing.mode') === EDIT_MODE_BATCH;

this.refresh();

const editIndex = getIndexByKey(key, this._editData);
if(editIndex >= 0) {
if(this._editData[editIndex].type === DATA_EDIT_DATA_INSERT_TYPE) {
this._removeEditDataItem(editIndex);
Expand Down
28 changes: 28 additions & 0 deletions testing/tests/DevExpress.ui.widgets.dataGrid/editing.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5036,6 +5036,34 @@ QUnit.test('deleteRow should works if cell value is changed', function(assert) {
assert.strictEqual(testElement.find('input').length, 0, 'no editors');
});

QUnit.test('deleteRow should works in row editing mode if boolean column and validation are exist (T865833, T864931)', function(assert) {
// arrange
const that = this;
const rowsView = this.rowsView;
const testElement = $('#container');

that.options.editing = {
mode: 'row',
allowDeleting: true
};

that.options.columns.push({ dataField: 'booleanField', dataType: 'boolean', validationRules: [{ type: 'required' }] });
that.columnsController.reset();
that.editingController.init();

rowsView.render(testElement);

// assert
assert.strictEqual(testElement.find('.dx-data-row').length, 7, 'row count');

// act
that.deleteRow(1);
that.clock.tick();

// assert
assert.strictEqual(testElement.find('.dx-data-row').length, 6, 'row is removed');
});

// T804894
QUnit.test('addRow should not work if updating is started with validation error', function(assert) {
// arrange
Expand Down

0 comments on commit caa1a6b

Please sign in to comment.