Hi,
I have a grid that will create multiple records in the database on Create/Update of any record in the grid. I would like to refresh the grid once the create/insert is complete so that all the newly created records will be visible to the user. How can I do that?
3 Answers, 1 is accepted
0
Accepted
Hi Raja,
You can listen for the save or saveChanges event of the Grid (depending on the edit mode you are using) and attach a dataBound handler to the Grid, which will be executed only once. Refresh the Grid dataSource in this dataBound handler with the .read() method of the DataSource. This will get the current records from the database and re-render the Grid using the latest data:
Regards,
Dimiter Topalov
Telerik
You can listen for the save or saveChanges event of the Grid (depending on the edit mode you are using) and attach a dataBound handler to the Grid, which will be executed only once. Refresh the Grid dataSource in this dataBound handler with the .read() method of the DataSource. This will get the current records from the database and re-render the Grid using the latest data:
function
onGridSave(e) {
e.sender.one(
"dataBound"
,
function
() {
e.sender.dataSource.read();
});
});
Regards,
Dimiter Topalov
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items
0
Dan
Top achievements
Rank 1
Veteran
answered on 21 Jul 2020, 09:38 PM
In case anyone else is wondering what working code, based on the above comment, looks like. Here is what is working for me:
This code works for both the Create and Update Grid events.
function
onGridEdit(e) {
e.sender.one(
"dataBound"
,
function
(e) {
e.sender.dataSource.read();
});
}
function
bindDataAndRefresh(e) {
var
grid = $(
"#upcoming-grid"
).data(
"kendoGrid"
);
grid.bind(
"dataBound"
, onGridEdit(e));
}
$(document).ready(
function
() {
var
grid = $(
"#upcoming-grid"
).data(
"kendoGrid"
);
grid.bind(
"save"
, bindDataAndRefresh);
});
Petar
commented on 23 Jul 2020, 09:56 AM
Telerik team
Hi Dan,
Thank you for sharing the code that worked on your end with the community! Your post will surely help someone in the future.
Regards,
Petar
Progress Telerik
0