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

Self referentail grid - with setting of expandable flag.

1 Answer 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
giridhar
Top achievements
Rank 1
giridhar asked on 04 Mar 2009, 02:57 PM
Hi,
  Currently I am working with self referential grid, I want to get first level of nodes once and when user clicks expand button, I want to get the second level of nodes from DB. To acheive this I want to set flag GridDataItem.CanExpand to true (since all the nodes may not be expandable).Unfortunately It says that the property "canexpand" is read only.

This is the blocker for my requirement.

Additionally I should be able to change the rows in detail tables and, in fact detail tables insertion and removal based on some external link clicks.

Please do let me know if following are possible.
Insert and Delete detail tables of self referential grid based on some external link clicks.
Instead of getting all levels of self-referential grid at time, if I can get only top most nodes and work on getting rest of nodes based on the expansion of grid rows(HierarchyLoadMode="serverOnDemand").

Any help would on this would really be a great favour.

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 09 Mar 2009, 12:16 PM
Hello Giridhar,

Thank you for getting back to us.

To expand only some of the items on grid load, you can set the Expand property of the GridDataItem. Below is a code excerpt which implements this approach:
    public void Page_PreRenderComplete(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.Items) 
        { 
            //You can expand a corresponding item depending on a Item field value. 
            if (item["FirstName"].Text == "Andrew"
            { 
                item.Expanded = true
            } 
        } 
    } 

Concerning the requirements to add and remove NestedView:
I should say that this is not a good approach. In order to create the nested view, you need to add it to the item when OnInit event of the page is raised. This should be done in order the grid to be able to create its child controls and to save the correct state of them. I suppose this is not convenient approach, because it’s early and you cannot determine when to add or delete NestedView depending on a GridDataItem field value. Here you can find more information related to programmatic creation of RadGrid.

I will suggest you use the depicted in the code snippet approach and to avoid adding nested views by hand.

For your convenience I attached the test project to this support thread..

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