I have templated columns in my grid which are inherited from Itemplate.
I am changing the page size, but after post back I dont see the expected number of rows, it still displays the same number of rows.
I did a grid.rebind() and now it just shows one more row after the post back is complete.
For eg:-
Current Page size : 6
Change Size to :10
After Postback : No Change in number of rows.
------------------------------
Rebind Scenario:-
Current Page Size : 6
Changes size to : 10
Rebind()
After PostBack : 7 rows in the page.
Could you please help me out in this case.
3 Answers, 1 is accepted
Could you paste your aspx and code-behind using the CodeFormatter tool of the ticket editor.
Thanks.
Greetings,Tsvetoslav
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items.
Hello Tsvetoslav,
Thanks for the reply.
I have some code snippets, though our application is complex I have tried to pull out the relevant code.
Let me try to explain a little further, in case I wasn’t clear. We have a page with a rad grid on it. Our page also allows the user to bring up a lightbox dialog which allows them to change the page size of the grid. When the user makes a change and chooses OK to save the new page size, a postback occurs and in our handling of this postback we want to change the page size of the grid.
In the debugger I set a breakpoint in the InstantiateIn method shown in the code below. During the postback processing, I count the number of times InstantiateIn is called.
In the postback, here is the sequence of events as we see them in the debugger (assuming the user changes the size of the grid from 10 rows to 15):
- Load of the page – InstantiateIn is called 10 times (the same as we would see for an initial page load)
- OK event handler triggers (causing us to change the page size to the newly configured size)
- We call the RadGrid Rebind() method to rebind the grid
- InstantiateIn is called 11 times (not 15, as we would expect).
We have our own grid class that contains the telerik grid as a member. Here is the init handling:-
| protected override void OnInit(EventArgs e) | |||||||||||||||||||||||||||||||||||||||
| { | |||||||||||||||||||||||||||||||||||||||
| base.OnInit(e); | |||||||||||||||||||||||||||||||||||||||
| m_grid = new AppGrid(); | |||||||||||||||||||||||||||||||||||||||
| m_grid.ID = "grid1"; | |||||||||||||||||||||||||||||||||||||||
| m_grid.AutoGenerateColumns = false; | |||||||||||||||||||||||||||||||||||||||
| m_grid.EnableViewState = false; | |||||||||||||||||||||||||||||||||||||||
| //TODO: set page size based on web part "size" property | |||||||||||||||||||||||||||||||||||||||
| m_grid.PageSize = CurrentPageSize; // starts at 10 – but in our scenario, the user reconfigures to be 15 | |||||||||||||||||||||||||||||||||||||||
| m_grid.AllowSorting = true; | |||||||||||||||||||||||||||||||||||||||
| m_grid.AllowMultiRowSelection = true; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.Selecting.AllowRowSelect = true; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.AllowKeyboardNavigation = true; | |||||||||||||||||||||||||||||||||||||||
| m_grid.AllowPaging = true; | |||||||||||||||||||||||||||||||||||||||
| m_grid.MasterTableView.TableLayout = GridTableLayout.Fixed; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.Resizing.AllowColumnResize = true; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.Resizing.ResizeGridOnColumnResize = false; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.AllowColumnsReorder = true; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ColumnsReorder += new GridColumnsReorderEventHandler(OnColumnsReorderedInternal); | |||||||||||||||||||||||||||||||||||||||
| // According to something I saw on the Telerik site, this option needs to be set to true | |||||||||||||||||||||||||||||||||||||||
| // to allow column reordering that inserts rather than swaps columns. But testing seems to | |||||||||||||||||||||||||||||||||||||||
| // indicate that this is not true. Either way, if we are going to persist column ordering | |||||||||||||||||||||||||||||||||||||||
| // to personalization, we may need this false so we get a postback (because personalization | |||||||||||||||||||||||||||||||||||||||
| // is persisted by ASP.NET as part of the page lifecycle. | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.ReorderColumnsOnClient = false; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.Selecting.AllowRowSelect = true; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.ColumnsReorderMethod = GridClientSettings.GridColumnsReorderMethod.Reorder; | |||||||||||||||||||||||||||||||||||||||
| m_grid.MasterTableView.AllowNaturalSort = false; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.ClientEvents.OnCommand = "function(){}"; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ItemDataBound += new GridItemEventHandler(Grid_ItemDataBound); | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.Scrolling.AllowScroll = true; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.Scrolling.UseStaticHeaders = true; | |||||||||||||||||||||||||||||||||||||||
| m_grid.ItemCreated +=new GridItemEventHandler(Grid_ItemCreated); | |||||||||||||||||||||||||||||||||||||||
| Controls.Add(m_grid); | |||||||||||||||||||||||||||||||||||||||
| // We wait until after the grid is added to the controls collection so we have a ClientID assigned. | |||||||||||||||||||||||||||||||||||||||
| m_grid.ClientSettings.ClientEvents.OnColumnResized = Grid.ClientID + "_GridColumnResized"; | |||||||||||||||||||||||||||||||||||||||
| // This update panel (which has nothing inside) is used as a target for postbacks when we | |||||||||||||||||||||||||||||||||||||||
| // want to force a partial postback without needing any update at the browser, | |||||||||||||||||||||||||||||||||||||||
| // such as when resizing a column (which only needs personalization to get updated at the server). | |||||||||||||||||||||||||||||||||||||||
| UpdatePanel panel = new UpdatePanel(); | |||||||||||||||||||||||||||||||||||||||
| Controls.Add(panel); | |||||||||||||||||||||||||||||||||||||||
| m_updatePanelClientId = panel.ClientID; | |||||||||||||||||||||||||||||||||||||||
| } | |||||||||||||||||||||||||||||||||||||||
|
|
I thought that your scenario was much simpler, however, given the information provided it is not possible to pinpoint the problem the more so that you have an overridden version of our RadGrid. Please, open up a support ticket and send a runnable example of your implementation so that we can debug it on our side.
Tsvetoslav
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items.