We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

validation using angualr js in synchfusion grid


Hi can you provide me an example of synchfusion grid validation

Tehcnology  must be 
Angular js, MVC

validation example like
1)required field,
2)range  vallidation like be between 1 and 16 
3)Is the user prevented from entering alphabetical characters
4) field validated to be mandatory and between 1 and 128 characters
5)validation errors displayed accordingly and the user prompted to correct them ( i.e. is there an error message and is the focus put back on the field generating the error
6)   Are preceding/trailing spaces trimmed from the entry in any field prior to validation?
7) how to make option field means do not want to apply validation

Waiting for your quick reply 
Thanks in advance 

1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team August 13, 2015 03:00 PM UTC

Hi Bharat,
 
Thank you for using Syncfusion products.
 
Your requirement have been achieved by the ValidationRules properties. Please find the below table,
 
        Queries
              Properties
required field
e-validationrules-required="true"
range  validation like be between 1 and 16 
e-validationrules-range="range"
 

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

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

 

            $scope.tools = ["add", "edit", "delete", "update", "cancel"];

            $scope.page = 2;

            $scope.data = obj;

            $scope.range = [0, 5];
        });

Is the user prevented from entering alphabetical characters
e-validationrules-number="true"
field validated to be mandatory and between 1 and 128 characters
e-validationrules-maxlength="16" e-validationrules-minlength="5"
 
While using maxlength we are facing the issue with “MaxLength and Minlength property is not working fine in Angular JS”. We have confirmed this as a defect and logged a defect report. So, We have created support incident under your account to track the status of this requirement. Please log on to our support website with the below link to check for further updates,
 
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
 
Please find the following code snippet :
 

var data = ej.Grid.prototype._tags[0].attr;

    for (var i = 0; i < data.length; i++) {

        if (data[i] == "validationRules.maxLength") {

            ej.Grid.prototype._tags[0].attr[i] = "validationRules.maxlength";

        }

        else if (data[i] == "validationRules.minLength") {

            ej.Grid.prototype._tags[0].attr[i] = "validationRules.minlength";

        }

    }
 

 
 
But we have provided a workaround by changing the observables.
how to make option field means do not want to apply validation
Please remove the validation property from the column
validation errors displayed accordingly and the user prompted to correct them ( i.e. is there an error message and is the focus put back on the field generating the error
No, It will not remove the validation until the user changes it correctly.
Are preceding/trailing spaces trimmed from the entry in any field prior to validation?
Yes, it takes an entry while giving space in the entries.
 
 
 
Please find the following code snippet and sample :
 

<div ng-app="employeeView">

    <div ng-controller="GridCtrl">

        <div ej-grid id="Grid" e-width="500px" e-datasource="data" e-allowsorting="true" e-allowPaging="true" e-toolbarsettings-showtoolbar="true" e-toolbarsettings-toolbaritems="tools" e-editsettings-allowdeleting=' true' e-editsettings-allowediting='true' e-editsettings-allowadding='true' >

            <div e-columns>

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

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

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

                <div e-column e-field="Title" e-headertext="Title" e-textalign="right" e-validationrules-required="true"></div>

                <div e-column e-field="City" e-headertext="City" e-textalign="right"></div>

                <div e-column e-field="Country" e-headertext="Country" e-textalign="right"></div>

            </div>

        </div>

    </div>
</div>

 
Sample Link : http://www.syncfusion.com/downloads/support/forum/119903/ze/ServerOperations_(2)455564011
 
Please get back to us if you need any further assistance.
 
Regards,
Prasanna Kumar N.S.V


Loader.
Live Chat Icon For mobile
Up arrow icon