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

[Solved] hierarchy bind to ObjectDatasource

1 Answer 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
TIGER
Top achievements
Rank 1
TIGER asked on 18 May 2009, 03:58 PM
RadGrid hierarchy is a very nice feature, but very little is explained in all the documents. An example is provided with Sqldatasource by setting the MasterField and DetailField and maintain a link by a select parameter like this:
            <SelectParameters>
                <asp:SessionParameter Name="CustomerID" SessionField="CustomerID" Type="string" />
            </SelectParameters>

the magic is that this SessionField does not need to be updated by any code after row change,  server side or client side. Maybe there's embeded special treatment for Sqldatasource ? I used an ObjectDatasouce as the datasource and how could I get the current MasterField value during the OnSelecting event of ObjectDatasource ? One solution could be getting the current  row in the masterview during OnHierarchyExpanding event and save it for selecting parameter of the childview. This way only one level of the master-detail hierarchy can be maintained (OnHierarchyExpanding event only attach to the MasterView). When tried to implement this fix I found out that OnHierarchyExpanding client event never fired off, is this a problem or something extra must be done to enable it besides setting the client event handler like this:
            <ClientEvents OnHierarchyCollapsing="OnHierarchyExpanding" />
I would be much appreciated if anyone could help me out here!!!

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 21 May 2009, 11:21 AM
Hello Tiger,

To achieve your goal I can suggest you to wire the ItemCommand event and to check whether the e.CommandName is "ExpandCollapse". If it is the item is expanding/collapsing. In this moment you can retrieve the Id of the row and save it a session or other store and to use it when you bind the inner Detail table with other ObjectDataSource.

The OnHierarchyExpanding event will be raised only if the HierarchyLoadMode is "Client". If you need to use other load modes you can wire the OnCommand event and check whether the command name is "ExpandCollapse".

Greetings,
Georgi Krustev
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
TIGER
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or