How to remove the RuleSetValidation using jquery in devExtreme dataGrid?

| By Webner

Introduction of Validation

Validation is the most important part of any programming language. The validation avoids saving invalid data in the database. It does not check the accuracy of the data but checks the format of data. With the help of validation, we can directly check if the field is blank or have invalid data. Sometimes we apply the validation in the MVC model and make some columns read-only to save the data into a database using Devextreme Datagrid. It gives an error message and the data is not saved in the database.

devextreme datagrid

It provides lots of features that we can use according to our needs. In this case “Migration Id” column is a read-only column and it’s getting a validation error when we try to save data into the database. The “CustomizeColumns” configuration feature of devextreme dataGrid is used. In the given example “removeValidationRules” function in javascript is made and call this function in the Datagrid “CustomizeColumns” to remove validation in the “MigrationId” column.

DataGrid Code in MVC

.Columns(columns => {
columns.AddFor(m => m.MigrationId);
columns.AddFor(m => m.Name);
columns.AddFor(m => m.IndexFile);
.Paging(paging => paging.PageSize(10))
.DataSource(d => d.WebApi().Controller(“DataGridCustomers”).Key(“ID”))

JavaScript Code

function removeValidationRules(columns)
columns[1].validationRules = null;

Leave a Reply

Your email address will not be published. Required fields are marked *