Welcome Guest Search | Active Topics | Sign In | Register

Get Grid Position When Page Reload Options
Rachel Tan
Posted: Sunday, July 12, 2009 6:52:47 AM
Rank: Newbie
Groups: Member

Joined: 7/11/2009
Posts: 8
Dear Sir,

I have a grid with about 50 rows.
So, if i want to edit 45th row, I click "Select" and trigger ItemChanged to query value and put under TextBox on same pages.
Then, I did some edit, and click ASP:button save. The whole page reload and the grid go back to Row 1.

How we can get the grid row selected position that stop at 45th rows ?
Thanks !!!
eo_support
Posted: Sunday, July 12, 2009 9:34:35 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

We are not exactly sure about your scenario and your steps to reproduce the problem. It will be better for you to post a test page demonstraging the problem.

The Grid should automatically save the current selected item when you post back. The value is stored in SelectedItemIndex property. If you rebind the Grid, this value will be reset and the Grid will go back to row 1. In this case you can store the previous SelectedItemIndex and then restore it again after you rebind the Grid. However you will also need to consider that the number of row may changes and the old SelectedItemIndex may be out of range. So you will need to code to handle that situation.

Currently the Grid does not automatically scroll a selected item into view. For example, if the Grid has 40 rows and only the first 20 rows are visible when the Grid's scroll position is on the top, the selected item won't be visible if it is the 30th row because the Grid does not automatically scrolls. We may add this in our next release. In the mean time you can use our client side JavaScript interface to make it visible:

Code: HTML/ASPX
<eo:Grid ClientSideOnLoad="on_grid_loaded" .....>
.....
</eo:Grid>


Code: JavaScript
function on_grid_loaded()
{
    //Get the grid object. NOTE: the code should be
    //&lt;%=Grid1.ClientID%&gt;, not "&lt;%=Grid1.ClientID%&gt;"
    var grid = eo_GetObject("&lt;%=Grid1.ClientID%&gt;");

    //Get the grid item. NOTE: the code should be
    //&lt;%=Grid1.SelectedItemIndex%&gt;, not
    //&lt;%=Grid1.SelectedItemIndex%&gt;
    var item = grid.getItem("&lt;%=Grid1.SelectedItemIndex%&gt;");

    //Scroll the item into view
    if (item)
        item.ensureVisible();
}


Thanks!

Rachel Tan
Posted: Sunday, July 12, 2009 1:10:31 PM
Rank: Newbie
Groups: Member

Joined: 7/11/2009
Posts: 8
Thank you for your prompt reply !!
You got my point, but your code doesnt work.
Hopefully your next release will include this function.
eo_support
Posted: Sunday, July 12, 2009 1:20:13 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

The code should work. However you can not copy and paste as is. You will need to modify the IDs accordingly. Also you need to read the comment and change "&lt;" to "<". The actually content should be "<", however it is incorrectly formatted as "&lt;" during the code coloring process.

Thanks!
Rachel Tan
Posted: Sunday, July 12, 2009 1:27:04 PM
Rank: Newbie
Groups: Member

Joined: 7/11/2009
Posts: 8
Hi,
Understand your point. I will try it again.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.