- Home
- Forum
- ASP.NET MVC
- How to prevent batch saving when grid columns are invalid
How to prevent batch saving when grid columns are invalid
Thanks for contacting Syncfusion support.
When the cells are being edited and while selecting a row, the edited row will save. If there is any invalid column, the validation message will pop-up. To avoid this, we suggest you to use rowSelecting event of ejGrid. This event triggers before the row going to be selected and we stop the validation message by defining args.cancel as true.
Please find the code example and sample:
|
@(Html.EJ().Grid<Sample119799.OrdersView>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) .AllowPaging() /*Paging Enabled*/ .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) .AllowSorting() .ToolbarSettings(toolbar => { toolbar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.Add); items.AddTool(ToolBarItems.Edit); items.AddTool(ToolBarItems.Delete); items.AddTool(ToolBarItems.Update); items.AddTool(ToolBarItems.Cancel); }); }) .ClientSideEvents(eve => eve.RowSelecting("action")) .Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("CustomerID").HeaderText("Customer ID").ValidationRules(v => v.AddRule("required",true).AddRule("minlength", 3)).Width(80).Add(); col.Field("EmployeeID").HeaderText("Employee ID").ValidationRules(v => v.AddRule("required",true)).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add(); }))
<script type="text/javascript"> function action(args) { if(this.model.isEdit) args.cancel = true; } |
Sample : http://www.syncfusion.com/downloads/support/forum/122107/ze/Sample119799-392805097
Refer to the Help document for the rowSelecting event
http://help.syncfusion.com/js/api/ejgrid#events:rowselecting
Regards,
Prasanna Kumar N.S.V
- After the Update button is clicked but before the batch changes are actually submitted, how can I determine the cells that are not valid
- If I can determine which cells are not valid, how can i trigger the display of the validation error message below the invalid cell.
Attachment: Captures_efd40312.zip
The reported issue “Validation message is not shown while adding new empty record in batch editing” has been reproduced at our end. We have considered it as the defect and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Regards,
Prasanna Kumar N.S.V
- 3 Replies
- 2 Participants
-
DF Debbie Facey
- Feb 17, 2016 03:48 PM UTC
- Feb 19, 2016 09:43 AM UTC