Skip to content

Commit

Permalink
DataGrid: Fix dataType changing at runtime (T667936) (#5231)
Browse files Browse the repository at this point in the history
  • Loading branch information
vconst authored Aug 30, 2018
1 parent 941ca9b commit 1dbbe2d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/ui/grid_core/ui.grid_core.columns_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ module.exports = {
that._updateLockCount--;
}
that._columnChanges = undefined;
if(columnChanges.optionNames && (columnChanges.optionNames.dataField || columnChanges.optionNames.lookup)) {
if(columnChanges.optionNames && (columnChanges.optionNames.dataField || columnChanges.optionNames.lookup || columnChanges.optionNames.dataType)) {
that.reinit();
} else {
that.columnsChanged.fire(columnChanges);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4700,6 +4700,40 @@ QUnit.test("update column dataField", function(assert) {
assert.strictEqual(columnsChangedArgs[0].optionNames.length, 1);
});

// T667936
QUnit.test("change column dataType", function(assert) {
this.applyOptions({ columns: ["id", "orderDate"] });

var columnsChangedArgs = [];

var items = [
{ id: 1, orderDate: "2018/08/30" },
{ id: 2, orderDate: "2018/08/31" }
];

var dataSource = new DataSource(items);

dataSource.load();

this.columnsController.applyDataSource(dataSource);

this.columnsController.columnsChanged.add(function(e) {
columnsChangedArgs.push(e);
});

// act
this.columnsController.columnOption('orderDate', "dataType", "date");

// assert
assert.strictEqual(this.columnsController.getColumns()[1].dataField, "orderDate");
assert.strictEqual(this.columnsController.getColumns()[1].dataType, "date");
assert.deepEqual(this.columnsController.getColumns()[1].filterOperations, ["=", "<>", "<", ">", "<=", ">=", "between"]);
assert.deepEqual(this.columnsController.getColumns()[1].calculateCellValue(items[0]), new Date(2018, 7, 30), "calculateCellValue for field with changed dataType");
assert.strictEqual(columnsChangedArgs.length, 1);
assert.strictEqual(columnsChangedArgs[0].optionNames.all, true);
assert.strictEqual(columnsChangedArgs[0].optionNames.length, 1);
});

// T346972
QUnit.test("change column option validationRules at runtime", function(assert) {
this.applyOptions({ columns: ["field1", "field2"] });
Expand Down

0 comments on commit 1dbbe2d

Please sign in to comment.