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

Rebinding Parent Grid after Detail update

3 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jake
Top achievements
Rank 1
Jake asked on 23 Feb 2009, 03:01 PM

Hello,

I have implemented a 2 level hierarchy using RadGrid with only the 2nd level being editable.

Everything works great unless after the update I force the Parent grid to rebind.  If I do this, the event which normally fires to reload the expanded detail grid (2nd level) does not fire causing a datakey cannot be found message to appear.  Not sure if anyone else has run into this issue and if it's documented anywhere.  I thought it would be useful information for anyone who may experience this in the future.

If you ask why I am attempting to rebind the Parent grid it is because the Master is an aggregate of data in the detail records.  So, I wanted to rebind in order to show updates values in the Master.  For now, I am disabling my call to rebind the Master and letting the user simply collapse the current detail or expand another in order for the grid to rebind itself.

 

Regards,

Jake

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 26 Feb 2009, 07:20 AM
Hello Jake,

Can you please provide more information about how, in which event you are handling the update and forcing the grid to rebind? Please note that you may need to cancel the event if you are explicitly rebinding the control. 

Greetings,
Rosen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jake
Top achievements
Rank 1
answered on 26 Feb 2009, 01:30 PM
I handle the update in the UpdateCommand bound to the grid.  This same update command fires whether for the master or detail tables in the grid.  At the end of the UpdateCommand, I reset the datasource for the grid and call DataBind.

I do not use the NeedDataSource event anywhere since I began implementing the grid prior to discovering it's existence.  I have my own methods which are called to set the datasource and bind.

It makes sense to me that if I reset the datasource and call DataBind that the datakey issue would occur since there is no way of knowing whether the underlying data has changed, so when the grid tries to expand the detail table after postback it fails.

If I should be using different events and/or ordering things differently let me know.

Regards,
Jake
0
Sebastian
Telerik team
answered on 02 Mar 2009, 02:50 PM
Hello Jake,

In order to suport hierarchical grid, you will need to switch to advanced binding via NeedDataSource event handling or assigning data source controls for each level of the grid hierarchy. Review the following online demos of the product for further details:

http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/declarativerelations/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/detailtabledatabind/defaultcs.aspx

and take into account that grid hierarchy is not supported with simple binding and DataBind() calls.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Jake
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Jake
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or