- Home
- Forum
- ASP.NET MVC - EJ 2
- Grid - Custom Validation
Grid - Custom Validation
Hello,

I'm trying to add a Custom Validation to a column, but I got a syntax error. I was following your documentation example:
We're using Syncfusion 16.4.0.44. In addition, this link is broken: https://ej2.syncfusion.com/16.1.24/aspnet/documentation/form-validator.html#defining-custom-rules
Thanks in advance.
SIGN IN To post a reply.
1 Reply
TS
Thavasianand Sankaranarayanan
Syncfusion Team
January 8, 2019 05:56 AM UTC
Hi Matias,
Greetings from Syncfusion.
Sorry for the inconvenience caused.
Query #1: I'm trying to add a Custom Validation to a column, but I got a syntax error. I was following your documentation example:
Currently, Grid do not have the tag helper support for custom validation rules. So we suggest you to use Grid Load event to achieve this requirement like as follows,
|
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.data).AllowPaging(true).Load("load").Columns(col =>
{
col.Field("OrderID").HeaderText("OrderID").IsPrimaryKey(true).Width("120").Add();
col.Field("CustomerID").HeaderText("CustomerID").Width("120").Add();
col.Field("EmployeeID").HeaderText("EmployeeID").Width("120").Add();
col.Field("ShipCity").HeaderText("ShipCity").Width("120").Add();
}).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render()
<script type="text/javascript">
function load(args) {
this.columns[1].validationRules = { required: true, minLength: [customFn, 'Need atleast 5 letters'] };
}
function customFn(args) {
return args['value'].length >= 5;
}
</script> |
Also we could see that we have used razor and tag helper to provide custom validation in our mvc and core help documentation code. We have already logged documentation task to change this code in the documentation. The changes will be available in any of our upcoming release.
Refer the below link to know about Grid Load event,
Query #2: In addition, this link is broken: https://ej2.syncfusion.com/16.1.24/aspnet/documentation/form-validator.html#defining-custom-rules
We suggest you to use below documentation and demo link to know about our form-validator instead of that link,
Regards,
Thavasianand S.
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
MP Matias Puzanowski
- Jan 7, 2019 01:46 PM UTC
- Jan 8, 2019 05:56 AM UTC