9 Answers, 1 is accepted
You can get the total count of rows in the PreRender event and there you can set the PageSize and Rebind the Grid.
C#:
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
int
rowCount;
RadGrid1.MasterTableView.AllowPaging =
false
;
RadGrid1.Rebind();
rowCount = RadGrid1.MasterTableView.Items.Count;
//get row count
RadGrid1.PageSize = rowCount;
//set page size
RadGrid1.MasterTableView.AllowPaging =
true
;
RadGrid1.Rebind();
}
Thanks,
Princy
int
rowCount;
radGridVessel.MasterTableView.AllowPaging =
false
;
radGridVessel.Rebind();
rowCount = radGridVessel.MasterTableView.Items.Count;
//get row count
radGridVessel.PageSize = (rowCount / 2) + 1;
//set for 2 pages
radGridVessel.MasterTableView.AllowPaging =
true
;
radGridVessel.Rebind();
The code presents an issue because on load, the first page will be correct proportionately, but when the next page button is pressed, the code is executed again, essentially halving the page size each time the button is pressed. How can I keep this to persist across changing pages?
I am not sure what exactly you want to persist across changing pages - the initial PageSize or not?
I have tested the provided code and it works as expected. When the grid is initially loaded the row count is set for 2 pages as it should be. After I change the page by clicking next/prev button or the number the PageSize is persisted. Once I change the PageSize value and start changing the pages again the new PageSize is displayed for the grid. You can also refer to this video which demonstrates how this approach is working on my end:
http://screencast.com/t/jpXf9Zx3Bu
If you expect something different, please elaborate more what is the desired behavior.
Regards,
Pavlina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Could you please try to replicate the described behavior in the project I sent you in the previous post and let me know what steps I should follow in order to observe it locally? Another option would be to isolate the problem in a sample runnable project and send it to us via Support ticket. Once we manage to replicate the issue we would be able to advice you further.
Regards,
Pavlina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Hi I'm having exactly the same issue.
I want to change radgrid default pageSize programmatically. Basically I want to give different radgrid PageSizes to different users.
after reloading the page it goes back to original default pageSize.
I'm using < PagerStyle Mode="NextPrevNumericAndAdvanced" ...........</PagerStyle>
<ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true" >
<Resizing AllowColumnResize="true" ResizeGridOnColumnResize="true" />
<DataBinding Location="xxxxxxx.asmx" SelectMethod="xxxxxxx" SelectCountMethod="SessionExpired">
</DataBinding>
<ClientEvents OnDataBound="RadGrid_DataBound" OnDataBinding="RadGrid_DataBinding" OnRowSelected="Radgrid_onItemSelect" OnRowDeselected="RadGrid_onItemDeSelect" OnRowContextMenu="xxxxxx"></ClientEvents>
<Selecting AllowRowSelect="True"></Selecting>
<Scrolling AllowScroll="true" UseStaticHeaders="true" />
</ClientSettings>
.
I don't want to use RadComboBox dropdown for pageSize.
Could you please help me on this ?
Cheers
Has
Hi Has,
I see your other thread with the same question is already answered: http://www.telerik.com/community/forums/change-radgrid-default-pagesize.
Regards,
Telerik by Progress