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

Scroll To/ Jump To certain row

3 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
alex
Top achievements
Rank 1
alex asked on 18 Jan 2008, 11:42 PM
I have a grid and want the ability to center the page on a certain row.


I am not using scrolling (or what ever that option is to create scroll bars, etc).

right now I am trying the following:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
 if (e.Item is GridDataItem)
            {
                String guidToScroll = Request.QueryString["guid"];
                if (!String.IsNullOrEmpty(guidToScroll))
                {
                    try
                    {
                        Guid scrollTo = new Guid(guidToScroll);

                        if (((MyObject)e.Item.DataItem).GUID == scrollTo)
                        {
                            (e.Item as GridDataItem).Selected = true;
                            (e.Item as GridDataItem).Focus();
                        }
                    }
                    catch { }
                }

            }

But focus doesn't center on the page (it cuts of part of the row actually), and after calling it firefox doesn't support click selection any more.

3 Answers, 1 is accepted

Sort by
0
Nikita Gourme
Top achievements
Rank 1
answered on 22 Jan 2008, 12:16 PM
I am not sure how bullet-proof and cross-browser your method is, however I searched in the online docs of RadGrid and a solution using the built-in grid scroll popped up:

Scrolling to the selected item

You may give it a spin

Nikita
0
alex
Top achievements
Rank 1
answered on 28 Jan 2008, 06:43 PM
With some modification, this worked.

How do I find what page an item is on?

I want to jump to the page as well that the desired item is located on (in addition to then scrolling to it).
0
Nikita Gourme
Top achievements
Rank 1
answered on 29 Jan 2008, 07:31 AM
To extend the solution in the way you would like to iterate through the entire set of data in the source to find the item of interest. Then, in accordance with the location of the item and the page size calculate on which page it will reside and change the page index for the grid to make that page active (for example on DataBound). Finally, scroll to the designated item.

Nikita
Tags
Grid
Asked by
alex
Top achievements
Rank 1
Answers by
Nikita Gourme
Top achievements
Rank 1
alex
Top achievements
Rank 1
Share this question
or