Syncfusion grid supports data annotations?

Hi,

I am using Asp.Net MVC Syncfusion grid.

 

I have applied data annotations on my business objects that I bind with syncfusion grid.

 

Data annotations, that run on client side (e.g. Required field annotation), are not working for the fields in the Syncfusion grid. Is there some setting required for running data annotations? Or Syncfusion grid doesn't support data annotations and we have to use javascript validations?

 

Please suggest what is best approach here.

 

Many Thanks.


1 Reply

GS Gowri S Syncfusion Team August 23, 2012 12:43 PM UTC

Hi Mohit,

Thanks for using Syncfusion Products.

Grid MVC will support Data annotation attributes. Please refer to the following code snippets:

[EditableOrder.cs]

public class EditableOrder

{

// Validation set to the orderId and customerId

[Required(ErrorMessage = "Order ID is required.")]

public int OrderID

{

get;

set;

}

[Required(ErrorMessage = "Customer  ID is required.")]

[StringLength(5, ErrorMessage = "Customer ID must be 5 characters.")]

public string CustomerID

{

get;

set;

}

.. . .

}

Add the following script files to your layout.cs within the head tag. Please refer to the following code snippets:

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>

 

       <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>

We have prepared the sample for your requirement and the same can be downloaded from the following link:

http://www.syncfusion.com/downloads/Support/DirectTrac/89849/Editing1742303737.zip


Also we would request you to check the following online sample link:

http://mvc.syncfusion.com/demos/ui/grid/Editing/CellEditType#

Please try this and let us know if you have any other queries.

Regards,

Gowri.S

Loader.
Up arrow icon