I was curious if there was some sort of callback event, specifically for Creating and Updating, that would allow the Grid to be refreshed after a transaction, ensuring data integrity?
Possible scenario: a user creates a row within the grid, and saves the changes. The row is created without an ID, as one is assigned after the SQL statement has executed. If the user then makes another change to that row, it has no ID to use to perform the SQL update correctly.
Any help would be much appreciated!
16 Answers, 1 is accepted


transport: {
read: {
url: "http://myurl.json"
},
create: {
url: "http://mycreate.json",
type: "POST",
complete: function(e) {
$("#grid").data("kendoGrid").dataSource.read();
}
},
......
I can't find this "complete" event anywhere in the documentation but after a lot of searching on here I found it. If you do a read() on your datasource then, the grid will update (or anything else you want to do in there).
I don't know if there is a better way, but this should work going off your description.

Thanks!

complete: function(e) {
$("#grid").data("kendoGrid").dataSource.read();
}
thanks a lot


the create/update methods return the modified data as response to the request.
The typical scenario is that fields such as "id" or "last_modification" are set by the database at INSERT or UPDATE
through triggers or sequences.
Just return the same json structure for the modified/created object (record) only as you did to initially populate the datasource (according to the datasource model). The datasource and grid will update themselves smoothly without any manual refresh code and without the additional roundtrip caused by calling read().
As a newbie to jquery / json programming I had quite a hard time to find this out - probably obvious to experienced web developers.



IQueryable<uspGetBillingRowResultSet0> billingRow = entitiesModel.UspGetBillingRow((int)Session["EmployeeId"], billing.BillingID).AsQueryable();
DataSourceResult result = billingRow.ToDataSourceResult(request);
return Json(result);
Returning the DataSourceResult for the created or updated row worked.


You mentioned that the manual refresh of the datasource is not neccessary if the create/update methods return
the modified data as response to the request. Just return the same json structure for the modified/created object (record) only as you did to initially populate the datasource (according to the datasource model). The datasource and grid will update themselves smoothly without any manual refresh code and without the additional roundtrip caused by calling read().
My question here is : how does the datasource and grid update themselves?
Actually I am trying ‘Save all changes with one request’ (http://www.telerik.com/support/code-library/save-all-changes-with-one-request)
solution. I modified UpdateCreateDelete() method to return modified data as response to the request. Now I want to make datasource and grid update themselves smoothly without the additional roundtrip caused by calling read().
Please suggest how I may do this.
public ActionResult UpdateCreateDelete([DataSourceRequest] DataSourceRequest request,
[Bind(Prefix = "updated")]List<
Order
> updatedOrders,
[Bind(Prefix = "added")]List<
Order
> newOrders,
[Bind(Prefix = "deleted")]List<
Order
> deletedOrders)
{
if (updatedOrders != null && updatedOrders.Count > 0)
{
for (int i = 0; i <
updatedOrders.Count
; i++)
{
var
target
=
orderList
.Where(o => o.OrderID == updatedOrders[i].OrderID).FirstOrDefault();
if (target != null)
{
int targetIndex = orderList.IndexOf(target);
orderList[targetIndex].OrderDate = updatedOrders[i].OrderDate;
orderList[targetIndex].EmployeeID = updatedOrders[i].EmployeeID;
orderList[targetIndex].OrderDescription = updatedOrders[i].OrderDescription;
}
}
}
if (newOrders != null && newOrders.Count > 0)
{
for (int i = 0; i <
newOrders.Count
; i++)
{
newOrders[i]
.OrderID
=
orderList
[orderList.Count - 1].OrderID + 1;
orderList.Add(newOrders[i]);
}
}
if (deletedOrders != null && deletedOrders.Count > 0)
{
for (int i = 0; i <
deletedOrders.Count
; i++)
{
var
target
=
orderList
.Where(o => o.OrderID == deletedOrders[i].OrderID).FirstOrDefault();
if (target != null)
{
orderList.Remove(target);
}
}
}
List<
Order
> responseOrders = new List<
Order
>();
responseOrders.AddRange(updatedOrders);
responseOrders.AddRange(newOrders);
responseOrders.AddRange(deletedOrders);
return Json(responseOrders.ToDataSourceResult(request, ModelState));
//return Json("Success!");
}
Thanks!




Thanking you in 2021 !!!, Steve for posting this solution to this problem. This solutions seems to be most elegant and most standard in comparision to the documentations provided by telerik team.
and yes , must say that though telerik provides some cool features, but documentation to support them are pathetic at times.. always the simplest possible solution.. and support on forum is so less.
Hi Rahul,
Indeed, when the Create request is sent and the response contains the updated data item, then the Grid will update automatically and there will be no need to manually refresh it. Please find the respective demo here:
https://demos.telerik.com/kendo-ui/grid/editing-inline
As per the quality of the documentation, we do our best to keep it up-to-date. Is it possible for you to share feedback on which part of the documentation should we focus on?
Thank you in advance.
Regards,
Tsvetomir
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.