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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use validation rules and create custom validation rules grid

Thread ID:





127659 Nov 30,2016 04:17 PM UTC Dec 9,2016 08:13 AM UTC ASP.NET Core 3
Tags: Grid
Asked On November 30, 2016 04:17 PM UTC

Hello forum
I cant seem to find how to use validation rules and custom validation rules on aspnet core on a grid,
if anyone could help me out with this I would highly appreciate it

Jayaprakash Kamaraj [Syncfusion]
Replied On December 1, 2016 03:17 PM UTC

Hi Angel, 
Thank you for contacting Syncfusion support. 
We can set validation rules to Grid Columns using below code example. Please refer to the below help document and code example. 
            .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) 
            .ToolbarSettings(toolbar => 
                   toolbar.ShowToolbar().ToolbarItems(items => 
            .Columns(col => 
                  col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Add(); 
                  col.Field("CustomerID").HeaderText("Customer ID").ValidationRules(v => v.AddRule("required", true).AddRule("minlength", 3)).Add(); 
                  col.Field("ShipCity").HeaderText("Ship City").Add(); 
                  col.Field("Freight").HeaderText("Freight").EditType(EditingType.Numeric).ValidationRules(v => v.AddRule("range", "[0,1000]")).Add(); 
                  col.Field("ShipCountry").HeaderText("Ship Country").Add(); 
We need to refer  jquery.validate.min.js and jquery.validate.unobtrusive.min.js scripts for validation. So, please refer to these script files in your sample. 
Jayaprakash K. 

Aravind Ashokkumar
Replied On December 8, 2016 04:53 AM UTC

Hi Team,

Since Net core does not widely support Razor syntax, could you please help us provide more examples with Tag Helper Syntax.
I would nee your help for adding validation rules using Tag Helper syntax.

For example, for ej-grid the tag helper syntax is

<ej-grid id="grid_sample" allow-paging="true" allow-resize-to-fit="true" allow-resizing="true" allow-sorting="true" allow-multi-sorting="true" allow-scrolling="true" allow-searching="true" >
                <e-column field="ToolTip" header-text="ToolTip"></e-column>
                <e-column field="Remark" header-text="Remark"></e-column>
                <e-column field="RecordStatus" header-text="Record Status"></e-column>
            <e-filter-settings filter-type="Menu"></e-filter-settings>
            <e-page-settings page-size="14" page-count="5"></e-page-settings>

Jayaprakash Kamaraj [Syncfusion]
Replied On December 9, 2016 08:13 AM UTC

Hi Angel, 
We have created a ASP.NET core sample with validations using tag helpers. Please refer to the below code example and sample. 
<ej-grid id="FlatGrid" allow-paging="true"> 
    <e-datamanager url="//mvc.syncfusion.com/Services/Northwnd.svc/Orders/?$top=45" offline="true"></e-datamanager> 
    <e-edit-settings allow-adding="true" allow-deleting="true" allow-editing="true" edit-mode="Normal" /> 
    <e-toolbar-settings show-toolbar="true" toolbar-items='new List<string>() { "add", "edit", "delete", "update", "cancel", "search" }' /> 
        <e-column field="OrderID" is-primary-key="true" header-text="Order ID" text-align="Right"  width="70"></e-column> 
        <e-column field="CustomerID" header-text="Customer ID" width="80" validation-rules='new Dictionary<string, object>() { { "required",true}, { "minlength",3} }' ></e-column> 

Jayaprakash K. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon