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

How do I navigate from a selectedItem up to that item's groupHeader?

2 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 2
Andy asked on 09 Mar 2011, 09:57 PM
In the Ajax radGrid, in the PreRender event, I have all the group headers collapsed. But if I use another control to select the item, I want to select it in the grid (that's working great) and expand that item's header.

foreach ( item in sender.MasterTableView.Items) {
    if (item is GridDataItem) {
        GridDataItem dataItem = (GridDataItem)item;
        if (curItem.Equals(dataItem.OwnerTableView.DataKeyValues(dataItem.ItemIndex)("JobNumber").ToString())) {
            dataItem.Selected = true;
            GridGroupHeaderItem groupHeader = default(GridGroupHeaderItem);
    // *** At this point, how do I navigate to the groupHeader from the dataItem?  
        }
    }
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 10 Mar 2011, 06:01 AM
Hello Andy,

Try the following code snippet to expand the group header of selected item.

C#:
foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))
        {
            GridItem[] children = groupHeader.GetChildItems();
            foreach (GridDataItem child in children)
            {
                GridDataItem childItem = child as GridDataItem;
                if (curItem.Equals(childItem.OwnerTableView.DataKeyValues(childItem.ItemIndex)("JobNumber").ToString()))               
                {
                       childItem.Selected = true;
                      groupHeader.Expanded=true;
                }
             }
        }

Thanks,
Princy.
0
Andy
Top achievements
Rank 2
answered on 14 Mar 2011, 02:20 PM
I'm surprised that there is no direct way to determine the header item from a selected item, but this does exactly what I need!

Thanks!
Tags
Grid
Asked by
Andy
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Andy
Top achievements
Rank 2
Share this question
or