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

DetailTable paging doesn't work

2 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
golddog
Top achievements
Rank 1
golddog asked on 25 Nov 2011, 10:42 PM
I have a RadGrid with a detail table which I want to page if there are enough data.  The main table must also allow paging as well.

I saw how detail tables' data are cleared when the main grid is rebound.  That makes sense, so I checked whether we're coming from the detail table before setting the main's data source:
protected void grdGroupings_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
    if (!e.IsFromDetailTable)
    {
        grdGroupings.DataSource = AppealGroupingService.Find(null, grdGroupings.CurrentPageIndex + 1, grdGroupings.PageSize);
    }
}

Unfortunately, when DetailTableDataBind is raised, my current page index is always zero, defined by
grdGroupings.MasterTableView.DetailTables[0].CurrentPageIndex

Even though the DetailTable's pager moves to highlight #2 (or whatever I hit), CurrentPageIndex is always zero, so I request, receive and display the first chunk of information from my service, regardless of what's highlighted in the pager.

What's the right way to have a detail table hang onto its index for paging?

Thanks,

Scott

 

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Nov 2011, 05:42 AM
Hello Scott,

Try the following code snippet in ItemCommand event.
C#:
protected void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
{
 if (e.CommandName == RadGrid.PageCommandName)
 {
   GridPagerItem item = e.Item as GridPagerItem;
   GridTableView tableview = item.Parent.Parent.NamingContainer as GridTableView;
   int currentPageIndex = tableview.CurrentPageIndex;
  }
}

-Shinu.
0
golddog
Top achievements
Rank 1
answered on 28 Nov 2011, 05:16 PM
Thanks Shinu, I found a different route this morning.

I'm using the OnDetailTableDataBind event to bind each page in succession.  The GridDetailTableDataBindEventArgs exposes both my CurrentPageIndex and PageSize attributes on its DetailTableView property, so I was able to use those to get Detail Table paging going.
Tags
Grid
Asked by
golddog
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
golddog
Top achievements
Rank 1
Share this question
or