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

CurrentPageIndex and DetailTables

5 Answers 160 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mats
Top achievements
Rank 1
Mats asked on 21 Jan 2010, 04:21 PM
Hi!

According to documentation the CurrentPageIndex is kept when a Rebind() of grid is performed.

This seems to be true if the paging is done in the MasterTableView. If paging is done in a DetailTable the CurrentPageIndex will always be 0 when rebinding.

Is this by design or should CurrentPageIndex be kept also for DetailTables at rebind?

Thanks
/Mats

5 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 27 Jan 2010, 07:29 AM
Hi Mats,

If you have hierarchical RadGrid the CurrentPageIndex of the details table is kept into the DetailTables which is of type GridTableView like RadGrid's MasterTableView.
If you want to get the value of the CurrentPageIndex from DetailTables you need to write the following code snippet:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
   if (e.CommandName == RadGrid.PageCommandName)
   {
      GridPagerItem item = e.Item as GridPagerItem;
      GridTableView view = item.Parent.Parent.NamingContainer as GridTableView;
      int currentPageIndex = view.CurrentPageIndex;
   }
}

Additionally I am sending you a simple example which illustrates how to get CurrentPageIndex from the parent RadGrid and from details table.

I hope this helps.

Regards,
Radoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mats
Top achievements
Rank 1
answered on 27 Jan 2010, 10:19 AM
Hi Radoslav!

Thanks for your answer and your example. But it does not really relate to my problem. I know how to access the CurrentPageIndex for detail table views.
The problem for me is that when the grid is rebound then the CurrentPageIndex for detail tables will be cleared (0). Meaning that user will lose page selections (in detail tables) made before the rebind.

To reproduce my problem in your example:
  1. Set RadGrid1.HierarchyDefaultExpanded=true.
  2. Add a button that will call RadGrid1.Rebind().
  3. Run example and change page of master table and one detail table.
  4. Press rebind button. Now the page index will be kept in master table but in detail table it vill be 0

So my question remains. Is this by design or is it a bug?

This is no longer a big issue for me since I've made my own saving and restoring of CurrentPageIndex for detail tables.

Thanks
/Mats

0
Radoslav
Telerik team
answered on 29 Jan 2010, 04:18 PM
Hi Mats,

Thank you for getting back to us.

I am afraid the described behavior is not a bug, but rather expected. By default when you rebind a parent grid table view in a hierarchical grid the state for the nested tables is lost. This is because the refresh action resets all previous settings applied for the nested controls to avoid ViewState inconsistencies/unexpected behavior.

If you need further assistance, do not hesitate to contact us again.

Sincerely yours,
Radoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Guillermo
Top achievements
Rank 1
answered on 23 Jun 2015, 01:24 PM

[quote]Hi Mats,

Thank you for getting back to us.

I am afraid the described behavior is not a bug, but rather expected. By default when you rebind a parent grid table view in a hierarchical grid the state for the nested tables is lost. This is because the refresh action resets all previous settings applied for the nested controls to avoid ViewState inconsistencies/unexpected behavior.

If you need further assistance, do not hesitate to contact us again.
[/quote]

 

Is there  a workaround to this, I'm trying to accomplish this very thing I and I find it impossible to set the details table pageindex after a parent rebind. Thank you,

Guillermo

0
Radoslav
Telerik team
answered on 24 Jun 2015, 08:18 AM
Hi Guillermo,

Could you please elaborate a bit more on your scenario? What do you try to achieve? When do you want to set the pageindex of the details tables on some user action or initially? Do these detail tables are rendered and visible (parent item is expanded)?

Looking forward for your reply.

Regards,
Radoslav
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Mats
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Mats
Top achievements
Rank 1
Guillermo
Top achievements
Rank 1
Share this question
or