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

Rebind Parent Grid on deletion of Child Grid Item

3 Answers 189 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Landon
Top achievements
Rank 2
Landon asked on 13 Jun 2013, 11:27 PM
Hi,

I currently have a Parent Grid which houses another grid in the Detail View. Each Item in the Detail grid has a "Revenue" column which rolls up into the Parent Item's fields. I'm already using the "grid.dataSource.read()" method to rebind my grid any time a new item is added (shown below). However, I cannot seem to find how to fire this same method after an item in the Detail Grid is Destroyed.
//Update Revenue at Bid Grid
var UpdateRevenueGrid_Bid = function () {
    var grid = $("#RevenueBranchesAtBidGrid").data("kendoGrid");
    grid.dataSource.read();
};

Is it possible to rebind the Parent Grid immediately after Destroy is called on the Detail Grid?

NOTE: I'm running Kendo UI Q1 2013 with Razor

Thanks,
Landon

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 14 Jun 2013, 06:51 AM
Hi Landon,


I would suggest you to bind to the change event of the dataSource of the child Grid and check if the current action is remove.
E.g.
.DataSource(dataSource => dataSource
    ...
    .Events(events => events.Change("change"))
    ...
)

function change(e) {
    if (e.action == "remove") {
        //rebind master grid
    }
}


I hope that this information was helpful for you.

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Landon
Top achievements
Rank 2
answered on 14 Jun 2013, 06:01 PM
Hi Dimiter,

This doesn't seem to solve my issue as it looks like the .Change event is being fired BEFORE the Destroy is complete. Because the Parent Grid is being rebound prior to the Delete, the Parent does not display the changes resulting from the Deleted Row. 

Is there a way to fire an Event AFTER the Destroy?

Since I need my Child Rows to roll up into the Parent Row I need them to be executed in this order:

  1. Delete Child Item
  2. Rebind Parent Grid
With the example you provided using the .Change event it is firing as follows:
  1. Rebind Parent Grid
  2. Delete Child Item
I hope this makes some sense. Any help would be appreciated!

Thanks,
Landon
0
Landon
Top achievements
Rank 2
answered on 14 Jun 2013, 06:12 PM
H Dimiter,

I managed to figure out the issue by using the "sync" Change Action. Since this is called after the "remove" it seems to work fine.

Thanks,
Landon
Tags
Grid
Asked by
Landon
Top achievements
Rank 2
Answers by
Dimiter Madjarov
Telerik team
Landon
Top achievements
Rank 2
Share this question
or