Skip to content

Commit

Permalink
Release 17.2.9
Browse files Browse the repository at this point in the history
Cherry-picked changesets:
  60812a9 Konstantin Volnyagin - DataGrid: Fix several problems with validationRules in form editing mode (T652579, T651049, T652602) (#4608)
  • Loading branch information
magroshenkova committed Jul 12, 2018
1 parent 602215e commit 45ea8b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/ui/form/ui.form.layout_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ var LayoutManager = Widget.inherit({
var fieldName = this._getFieldLabelName(item),
validationRules = this._prepareValidationRules(item.validationRules, item.isRequired, item.itemType, fieldName);

if(Array.isArray(validationRules)) {
if(Array.isArray(validationRules) && validationRules.length) {
this._createComponent($editor, Validator, {
validationRules: validationRules,
validationGroup: this.option("validationGroup")
Expand Down
1 change: 1 addition & 0 deletions js/ui/grid_core/ui.grid_core.editing.js
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,7 @@ var EditingController = modules.ViewController.inherit((function() {
}
if(item.isRequired === undefined && column.validationRules) {
item.isRequired = column.validationRules.some(function(rule) { return rule.type === "required"; });
item.validationRules = [];
}

var itemVisible = typeUtils.isDefined(item.visible) ? item.visible : true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9369,7 +9369,7 @@ QUnit.test("Required mark should be rendered for column with validationRules whe
},
columns: [{
dataField: 'name',
validationRules: [{ type: "required" }]
validationRules: [{ type: "required", message: "Name!" }, { type: "stringLength", max: 20 }]
}, {
dataField: "lastName",
formItem: {
Expand All @@ -9388,6 +9388,10 @@ QUnit.test("Required mark should be rendered for column with validationRules whe
assert.equal($rowElement.find(".dx-validator").length, 2, "validator count");
assert.equal($rowElement.find(".dx-field-item").eq(0).find(".dx-field-item-required-mark").length, 1, "required mark in first item");
assert.equal($rowElement.find(".dx-field-item").eq(1).find(".dx-field-item-required-mark").length, 0, "no required mark in second item");
var firstValidationRules = $rowElement.find(".dx-validator").eq(0).dxValidator("option", "validationRules");
assert.equal(firstValidationRules.length, 2, "two validation rules for first column"); // T652579, T651049
assert.equal(firstValidationRules[0].message, "Name!", "first validation rule has correct message"); // T652602
assert.equal(firstValidationRules[1].type, "stringLength", "second validation rule type for first column"); // T652579, T651049
});

// T472946
Expand Down

0 comments on commit 45ea8b9

Please sign in to comment.