Articles in this section
Category / Section

How to set “validationRules” property of columns in JavaScript Grid?

1 min read

How to set validationRules” property of columns in JavaScript Grid.

Solution

We can set all the standard validation methods of jQuery as a validation rules for columns. In the below table we have listed some of the jQuery validation methods and explain how to set these rules for columns in AngularJS

Rules

Description

required

Requires an element.

minlength

Requires the element to be of given.

maxlength

Requires the element to be of given maximum length.

range

Requires the element to be in a given value range.

number

The element requires a decimal number.

rangelength

Requires the element to be in given value range



 

Please find more jQuery validation methods from the below UG documentation link

Link:
https://help.syncfusion.com/js/grid/editing#column-validation

Please find the below code snippet:

<div ej-grid id="Grid" e-datasource="data" e-toolbarsettings="toolbar" e-editsettings = "editing">

        <div e-columns>

            <div e-column e-field="EmployeeID" e-headertext="Employee ID" e-isprimarykey ="true" e-validationrules-required="true" e-validationrules-number="true"></div>

            <div e-column e-field="LastName" e-headertext="Last Name"></div>

            <div e-column e-field="FirstName" e-headertext="First Name" e-validationrules-maxlength="16" e-validationrules-minlength="5"></div>

            <div e-column e-field="Title" e-headertext="Title" e-validationrules-range="range"></div>

        </div>

    </div>

    <script>

        angular.module('listCtrl', ['ejangular'])

          .controller('EmployeeView', function ($scope) {

              $scope.data = window.employeeView,

              $scope.toolbar = { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel"] },

              $scope.editing = { allowEditing: true, allowAdding: true, allowDeleting: true },

              $scope.range = [0, 5]

          });

    </script>


 

Result:

 

 

Conclusion

I hope you enjoyed learning about how to set “validationRules” property of columns in JavaScript Grid.

You can refer to our JavaScript Grid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.  You can also explore our  JavaScript Grid example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!


Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied