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

Expand only one of many detailsTable by DataKey in Hierarchy Grid

2 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
B
Top achievements
Rank 1
B asked on 17 Oct 2008, 08:48 PM
I'm having difficulty expanding / selecting a specific detail table within a hierarchy grid. I have:
 Plans [MasterTableView] >
            Goals [DeatilsTableView] >
                     Objectives[DetailsTableView]

I need to select say only Objective 3 by its DataKey [as Im passing ObjectiveId via the querystring to this page]. I seem to be only able to expand all the objectives, when I need to just 'expand to' or 'show selected' whatever ObjectiveId row...  Here's my function...am I even close...or is there an easier way?                                                                                                                  protected void ExpandToObjectives()
    {
        string sObjectiveId = Request.QueryString["ObjectiveId"].ToString();

        RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;

        foreach (GridTableView gtv in RadGrid1.MasterTableView.DetailTables)
        {
            if (gtv.Name == "Goals")
            {
                foreach (GridTableView gtv1 in gtv.DetailTables)
                {
                   
                        if (dataItem.GetDataKeyValue("ObjectiveId").ToString() == sObjectiveId)
                            dataItem.Selected = true;
                  
                }
            }
        }
    }                                                                                                                                                                                      

2 Answers, 1 is accepted

Sort by
0
B
Top achievements
Rank 1
answered on 17 Oct 2008, 09:42 PM
Made some progress...I did/can find the datakey in the Plans masterTable now but can't seem to get into the details tables and make whatever rows pk make that row selected...? The code below works for plans...


 protected void Page_PreRenderComplete(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
 
            //Plans...it works
            foreach (GridDataItem gdi in RadGrid1.MasterTableView.Items)
            {
                if (gdi.GetDataKeyValue("PlanId").ToString() == Request.QueryString["EntityId"].ToString())
                    gdi.Expanded = true;   //gdi.Selected = true;
            }

          
    }
0
Sebastian
Telerik team
answered on 20 Oct 2008, 01:15 PM
Hello B,

How to traverse grid items in hierarchy (in order to achieve the drilling functionality you are searching for) you can see from the following topic in the online documentation:

http://www.telerik.com/help/aspnet-ajax/grdtraversingdetailtablesitemsingrid.html

Furthermore, if you use HierarchyLoadMode = Client you may consider taking advantage of the ExpandHierarchyToTop() method from the server-side API of the control:

http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Hierarchy/HierarchyLoadModeClient/DefaultCS.aspx (see the Page_PreRenderComplete handler)

Best regards,
Stephen
the Telerik team

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