I'm switching over our grids from our outdated infragistics grids.
One feature that was on the infragistics was that on Demand On Load on a grid, so you expand a row and it hits server and pulls child back. So like the RadGrid's ServerOnDemand.
What I'm trying to re-create but having problems, is that once those child items have been loaded, client should be able to collpase and expand that row without hitting the server but now the client has the data for that row. but I can't figure out how to do that using the RadGrid.
I'm using the AjaxManager as well.
So is this even possible?
So quick summary
click row, hits server gets child items display
On collpase it client collpases dosn't hit server ( can't figure this out)
if you expand the same row or a row that has already been expanded then you expand it using client and don't hit server (just show what you already know)
5 Answers, 1 is accepted
0
Hello Fred,
RadGrid does not support this behavior out-of-the-box. Nevertheless, you can easily implement it using NestedViewTemplate and another RadGrid inside.
You can find attached a small web site I have created that demonstrates this approach. Note that we initially do not bind the inner details grid to any data. We bind it only if the parent data item is expanded. RadGrid's client-side OnHierarchyExpanding event is used find the inner grid's client object and check if it contains any data. If not, we rebind the inner grid only.
I believe you can safely use this approach for your project needs.
Regards,
Veli
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.
RadGrid does not support this behavior out-of-the-box. Nevertheless, you can easily implement it using NestedViewTemplate and another RadGrid inside.
You can find attached a small web site I have created that demonstrates this approach. Note that we initially do not bind the inner details grid to any data. We bind it only if the parent data item is expanded. RadGrid's client-side OnHierarchyExpanding event is used find the inner grid's client object and check if it contains any data. If not, we rebind the inner grid only.
I believe you can safely use this approach for your project needs.
Regards,
Veli
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
mike
Top achievements
Rank 1
answered on 06 Jan 2010, 08:58 PM
I'm using an older version of the Telerik controls and this sample seems to fail on the nestedItem.ParentItem line. I read the ParentItem property was added in a later version. Upgrading isn't an option at this moment, is there a possible workaround?
Thanks.
Thanks.
0
Hi mike,
So, in ProductGrid's NeedDataSource event, instead of:
you can do:
The two approaches are equivalent
Regards,
Veli
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
So, in ProductGrid's NeedDataSource event, instead of:
GridDataItem parentItem = nestedItem.ParentItem;string dataKeyValue = parentItem.GetDataKeyValue("CategoryID").ToString();you can do:
GridTableView ownerTable = nestedItem.Parent.Parent as GridTableView;GridDataItem parentItem = ownerTable.Items[ownerTable.Items.Count - 1];string dataKeyValue = parentItem["CategoryID"].Text;The two approaches are equivalent
Regards,
Veli
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
mike
Top achievements
Rank 1
answered on 08 Jan 2010, 05:16 PM
Veli,
Unless I'm missing something. This line will always return back the data item for the last item in the parent grid. So this code only works when expanding the last item.
I believe what we actually want is the parent data item relative to the nested item we are trying to populate.
Thanks for your help,
Mike
Unless I'm missing something. This line will always return back the data item for the last item in the parent grid. So this code only works when expanding the last item.
| GridDataItem parentItem = ownerTable.Items[ownerTable.Items.Count - 1]; |
I believe what we actually want is the parent data item relative to the nested item we are trying to populate.
Thanks for your help,
Mike
0
Hello mike,
Please, excuse me for misleading you. I must have been mistaken with another example by the time of writing the reply. Older versions of RadGrid that do not expose the ParentItem property in the GridNestedViewItem, also do not support some of the client-side API that I have used in the demo project we are referring to. Therefore, for these older versions of the grid, the approach is entirely different.
We need to put a submit button inside the NestedViewTemplate and hide it. We will need it to postback and rebind the inner grid back on the server.
Additionally, we need a hidden input on the page. This input will hold the parent data key value, i.e. the key value of the expanded item. We will need it back on the server, as there is no straightforward way we can get to the parent data item from the inner grid's NeedDataSource event.
Attaching a version of the sample project significantly modified to support the scenario with RadGrid 2008.Q1 . Seems to work OK. Check it out.
Best wishes,
Veli
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Please, excuse me for misleading you. I must have been mistaken with another example by the time of writing the reply. Older versions of RadGrid that do not expose the ParentItem property in the GridNestedViewItem, also do not support some of the client-side API that I have used in the demo project we are referring to. Therefore, for these older versions of the grid, the approach is entirely different.
We need to put a submit button inside the NestedViewTemplate and hide it. We will need it to postback and rebind the inner grid back on the server.
Additionally, we need a hidden input on the page. This input will hold the parent data key value, i.e. the key value of the expanded item. We will need it back on the server, as there is no straightforward way we can get to the parent data item from the inner grid's NeedDataSource event.
Attaching a version of the sample project significantly modified to support the scenario with RadGrid 2008.Q1 . Seems to work OK. Check it out.
Best wishes,
Veli
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.