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

Jumping to Group Begining

2 Answers 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Henry Derstine
Top achievements
Rank 1
Henry Derstine asked on 23 Oct 2008, 03:10 PM
I was wondering if there is a way to jump to a specific group in the grid. I have a grid that has paging turned on. The groups are spread across the pages and I would like to allow the user to jump to page X where Group 3 starts.
Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Oct 2008, 06:48 AM
Hi,

Try the code snippet below to achieve the scenario. Here I  group based on the "ContactName"  and then on clicking the button I  jump to a page with a specific grouping  eg in this case: "Annette Roulet"

CS:
  protected void Button1_Click(object sender, EventArgs e) 
        { 
            int count = RadGrid1.MasterTableView.PageCount; 
            int flag = 0
            for (int i = 0; i < count; i++) 
            { 
                RadGrid1.CurrentPageIndex = i; 
                RadGrid1.Rebind(); 
                foreach (GridItem item in RadGrid1.MasterTableView.Controls[0].Controls) 
                { 
                    if (item is GridGroupHeaderItem) 
                    { 
                        GridGroupHeaderItem Item=(GridGroupHeaderItem)item; 
                        string strText = Item.DataCell.Text; 
                        string[] arr = strText.Split(':'); 
                        if (arr[1].TrimStart() == "Annette Roulet") 
                            { 
                                flag = 1
                                break; 
                            } 
                               
                    } 
                } 
                if (flag == 1) 
                    break; 
            } 
        } 


Thanks,
Princy
0
Henry Derstine
Top achievements
Rank 1
answered on 28 Oct 2008, 01:24 PM
Thanks that did the trick. Just two additional points.
1) You have to account for the style formatting in the comparison.
2) You have to adjust the comparison to allow for addtional info in the group header.

This is what I ended with-

If

arr(1).TrimStart().StartsWith("<strong>" & CType(e.Item.FindControl("DropDownList1"), DropDownList).SelectedValue & "</strong>") Then

Where the dropdown held the grouping I wanted to jump to.  I was thinking of using a contains instead of startswith but I wasn't sure I wanted to be that vague.

 

Tags
Grid
Asked by
Henry Derstine
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Henry Derstine
Top achievements
Rank 1
Share this question
or