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

Adding Items in the heirarchy when item is expanded

7 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Albert
Top achievements
Rank 1
Albert asked on 12 Dec 2008, 08:17 AM
The Item Command fires too late so the Item I added won't be rendered. Is there a way to find out the opened heirarchy on the Page_Load event?

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Dec 2008, 09:54 AM
Hi Albert,

You can check whether an grid row is expanded or not in the PreRender event of the Grid as shown below.

CS:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
            if (item.Expanded) 
            { 
 
            } 
        } 
    } 


Shinu
0
Albert
Top achievements
Rank 1
answered on 13 Dec 2008, 08:16 AM
Still wont work. Can someone plz help me on this part.

PseudoCode:

if (e.CommandName == RadGrid.ExpandCollapseCommandName)
     if (e.Item.Expanded == false)
          AttachTableView(e.Item.OwnerTableView.DetailTables);
--
AttachTableView(GridTableViewCollection TableCollection){
     GridTableView GTV = new GridTableView();
     ...*assign columns / datasource to GTV*
     TableCollection.Add(GTV);
}

Anyways, that should have made a new table on the heirarchy everytime I drop-down but its not showing. Plz help
0
Albert
Top achievements
Rank 1
answered on 15 Dec 2008, 04:03 AM
Up
0
Albert
Top achievements
Rank 1
answered on 16 Dec 2008, 01:45 AM
Bump
0
Sebastian
Telerik team
answered on 16 Dec 2008, 07:43 AM
Hello Albert,

Adding detail tables dynamically inside the ItemCommand handler is not a proper approach because this is a postback event handler and the viewstate of the newly added nested tables will not be persisted/will become corrupted on subsequent submits.

If you want to generate the tables on demand, there are two possible options:

  1. Choose HierarchyLoadMode = ServerOnDemand (default mode) for your hierarchy. The supported hierarchy load modes are outlined in this help article.
  2. Generate the grid programmatically inside the PageInit handler of the page as explained here:

    http://demos.telerik.com/aspnet-ajax/Grid/Examples/Programming/Hierarchy/DefaultCS.aspx
    http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html
Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Albert
Top achievements
Rank 1
answered on 16 Dec 2008, 09:55 AM
So there is no other way? What I need is to create new detailtables and attach it to newly expanded heirarchies.

Like
Customer
   >> Orders
           >> Order_Details
           >> Employees
                >> Orders
   >> CustomerDemographics
          >> Customer
                  >> Orders
                       >> Order_Details
                       >> Employees
That heirarchy will never end, so I can't make it on init coz it will loop forever. But by adding it on expand... I can make the same structure.
>_>
0
Sebastian
Telerik team
answered on 16 Dec 2008, 11:04 AM
Hello Albert,

The dynamical hierarchy structure you describe is not supported with standard hierarchy. As an alternative you may consider utilizing the self-referencing hierarchy feature of our web grid presented here:

http://demos.telerik.com/aspnet-ajax/Grid/Examples/Hierarchy/SelfReferencing/DefaultCS.aspx

Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Albert
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Albert
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or