This is a migrated thread and some comments may be shown as answers.

Reload on Closing Grid without Editing Data

2 Answers 10 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jackie
Top achievements
Rank 1
Jackie asked on 01 Sep 2017, 09:44 PM

I'm looking for a way to reload my grid's data, when users use the "Update" button to exit out of the popup editor, without having actually edited any data. As far as I can tell, unless a user edits some data before hitting "Update," no event is fired. Is that correct?

I have an odd situation where I need the grid to reload its data even if no data has been edited. Is there a way for me to do that?

2 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 05 Sep 2017, 02:15 PM
Hi Jackie,

You can use the Grid save event to check whether the row has been edited by the user and if it hasn't, trigger a Grid DataSource read manually:
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>()
    .Name("grid")
    .Events(events => events.Save("onSave"))

function onSave(e) {
    if (!e.model.dirty) {
        e.sender.dataSource.read();
    }
}

When an item value is edited, the dirty property of the item model is internally set to true. In the case you described, when there are no changes to the item, it will be false and the Grid will not trigger a save and read by itself for optimization purposes.

Regards,
Tsvetina
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jackie
Top achievements
Rank 1
answered on 05 Sep 2017, 04:04 PM
Thank you Tsvetina! That works perfectly.
Tags
Grid
Asked by
Jackie
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Jackie
Top achievements
Rank 1
Share this question
or