- Home
- Forum
- ASP.NET Core - EJ 2
- Working with validations on ejs-grid MVC core
Working with validations on ejs-grid MVC core
Hello Team,
I have a MVC core project and it used ejs grid. PLS ignore the selection made above
Assume i have a fresh record, with no details in the grid (mode = "NORMAL"). The Grid is empty and have 3 columns
1) a Docket #, (select via typing - autocomplete)
2) inhandpieces (not editable)
3) issued pieces. (editable, only number with max limit of column 2)
4) Action columns with Save and cancel icon (NOT THE TOOLBAR)
When the grid loads i use addRecord() to add a blank row by default. which means first row is in edit mode and has save and cancel icon in the last column
Now in the first column, there is auto-complete control (not Syncfusion one). I type 3 letters and basis the same i make an ajax post request and the data is successfully returned. This data has "InhandPcs" property with a value of 10. Now on the success of the ajax i need to
1) set the cell value of Inhandpcs in 2nd column
2.a) Add a validation for max (the issue value should not be > 20) in Issued pcs column . as soon as i type a value greater than inhand piecs (20) it should flag a validation error
2.b) Alternatively, if 2.a is not feasible, when i click on Save, it should fire the validateion (for 2.a), BUT the gird should not be refereshed and should stay in the same state as it was while editing with the same entered values.. the row should not go blank.
PLS NOTE I DNT WANT THE TOOLBAR
Can this be possible. I already spent a day, but was not able to figure otut. The AI promept misleads big time
Hi Pratik,
Greetings from Syncfusion support.
Query 1: When the grid loads i use addRecord() to add a blank row by default. which means first row is in edit mode.
In your update, you have mentioned that you are using the addRecord method to show the blank row. However, your requirement can be easily achieved by enabling the “editSettings.showAddNewRow” property of the EJ2 grid which will always display a new record at the top of the grid in editable mode. Please refer to the below documentation for more details on the same.
Documentation: https://ej2.syncfusion.com/aspnetcore/documentation/grid/editing/in-line-editing#show-add-new-row-always-in-grid
Query 2: set the cell value of Inhandpcs in 2nd column.
Your requirement can be achieved by changing the value of the required column by getting the input element from the form element and changing the value of the input element in the change event of the AutoComplete component of the first column. Please refer to the below documentation for more details on how to set the value of the a column based on the value selected in another column.
Query 3: Add a validation for max (the issue value should not be > 20) in Issued pcs column . as soon as i type a value greater than inhand piecs (20) it should flag a validation error.
Your requirement can be achieved by utilizing the custom validation feature of the EJ2 Grid. Please refer to the below documentation where we have explained in detail how to apply the validation rules based on the value selected in the dropdown list.
Documentation: https://ej2.syncfusion.com/aspnetcore/documentation/grid/editing/validation#custom-validation-based-on-dropdown-change
Regards,
Joseph I.
- 1 Reply
- 2 Participants
-
PS Pratik Shah
- Jun 15, 2026 11:47 AM UTC
- Jun 17, 2026 10:38 AM UTC