Dear Syncfusion,
I have been a week using Syncfusion and would like your advice per subject, how to perform server validation on Grid Excel Like edit.
For instance I add 5 lines of sales order items (Item, Qty, Price and Discount). I need to validate if :
- Discount of each item is should be less than specific value (need to read discount master table)
- Sum of all price * qty should be higher than specific value (need to read salesperson table)
Thanks in advance.
Hi Hariharan,
Thanks for the response.
Is any progress on the solution ?
I manage to solve the issue, but I need to re-code all, including build my own jquery grid :(
Hi Arief Darmawan,
Thanks for your interest in Syncfusion products.
We are Sorry for the inconvenience caused. We have prepared a sample to demonstrate the Server Side Validation in Excel like Edit.
In that sample we have done the validation based on the Quantity and Unit Price Value. The product of Quantity and Unit Price of an each item is greater than 500. If the validation is success then update the record to the database, otherwise it is simply display the error message using Response.AddHeader method.
Please refer the below code snippet for Server side Validation.
[Controller]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult BulkSave([Bind(Prefix = "updatedRecords")]IEnumerable<EditableOrder> orders, [Bind(Prefix = "addedRecords")]IEnumerable<EditableOrder> addRcrds, [Bind(Prefix = "deletedRecords")]IEnumerable<EditableOrder> delRcrds)
{
string msg=string.Empty;
if (orders != null)
{
foreach (var ord in orders)
{
if ((ord.Quantity * ord.UnitPrice) > 500)
{
OrderRepository.Update(orders);
}
else
{
msg = "Total Amount is less than 500 for the OrderID-"
+ord.OrderID;
Response.AddHeader("Error", msg);
}
}
}
if (addRcrds != null)
OrderRepository.Add(addRcrds);
if (delRcrds != null)
OrderRepository.Delete(delRcrds);
var data = OrderRepository.GetAllRecords();
return data.GridJSONActions<EditableOrder>();
}
[Cshtml]
<div class="Status" style="color: red; font-family: ‘Times New Roman';">
</div>
[Script]
<script type="text/javascript">
$("#Json").ajaxSuccess(function (evt, request, settings)
{
$('.Status').html(request.getResponseHeader("Error"));
});
</script>
For your convenience we have attached a sample. Could you please refer that sample and get back to us if you have any queries.
Let us know if you have any other concerns.
Thanks & Regards,
Satheeskumar S