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

Rowindex resets at each page

1 Answer 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 23 Jan 2014, 08:17 PM
A page requires that the value of RowIndex continue to increase when I go to the next page, yet it resets to 0 in the first column of each page.

I want the index to be 0, 1 , 2 , 3 on the first page, then 4, 5, 6, 7 on the next page; however, on the next page it would go to 0, 1, 2, 3 instead of continually increasing. Does anyone have any idea why this would be happening?

Here are the attributes of the grid:
<telerik:RadGrid ID="_EmpGrid" Skin="Web20" GridLines="None" runat="server" PageSize="10"
        AllowPaging="True" OnItemCreated="_EmpGrid_ItemCreated">

This is the Javascript behind the grid
            function ShowEditPanel(id, title_id, rowIndex)
{
                var grid = $find("<%= _EmpGrid.ClientID %>");

                var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
                grid.get_masterTableView().selectItem(rowControl, true);

                window.radopen("EmpPanel.aspx?EmpId=" + id + "&TitleId=" + title_id + "&Key=" + rowIndex, "EmpDialog");
                return false;
        }

and this is the function the grid calls upon

 protected void _EmpGrid_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                HyperLink editLink = (HyperLink)e.Item.FindControl("_EditLink");
                editLink.Attributes["href"] = "#";
                editLink.Attributes["onclick"] = String.Format("return ShowEditPanel('{0}', '{1}', '{2}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Employee_ID"], e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Employee_title_Id"], e.Item.ItemIndex);
            }
        }

1 Answer, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 24 Jan 2014, 05:40 AM
Hello,

int index =  e.Item.ItemIndex + (RadGrid1.CurrentPageIndex * RadGrid1.PageSize);
e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Employee_title_Id"], index);


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or