
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Albert Shenker
asked on 11 Jan 2012, 05:54 PM
I have a grid which is in a user control. The grid is displayed in various sized containers in my application depending on the page its on. Ideally, I would like to make it so the grid's initial page size (the number of rows dipslayed on each grid page) is calculated from the avaialable height. In this way, I can avod the user ever having to scroll the grid results vertically. Of course, if they change the size of their window, scrolling may become necessary, but I'm not concerned about this scenario.
Is there a way to calculate the available height for the grid rows and set the grid pageSize property based on this height prior to binding? I don't believe its possible to set the pagesize through client-side code, so somehow the client-side height availability calculation would have to be transferred to some server-side code whcih actually adjusts the grid pageSize property on initial loading of the page.
Is there a way to calculate the available height for the grid rows and set the grid pageSize property based on this height prior to binding? I don't believe its possible to set the pagesize through client-side code, so somehow the client-side height availability calculation would have to be transferred to some server-side code whcih actually adjusts the grid pageSize property on initial loading of the page.
7 Answers, 1 is accepted
0

Richard
Top achievements
Rank 1
answered on 12 Jan 2012, 04:59 PM
Albert:
Not sure if you've seen this Code Library project yet, but it should prove very useful to you in working through a solution.
How to set RadGrid height client-side with Javascript
Hope this helps!
Not sure if you've seen this Code Library project yet, but it should prove very useful to you in working through a solution.
How to set RadGrid height client-side with Javascript
Hope this helps!
0

Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 12 Jan 2012, 06:12 PM
Thanks for the info, but I'm not sure that project gets me where I'm trying to go. I'm not looking to resize my grid or the scroll height. The grid already occupies 100% of the height available and the scrolling works as expected. What I'm trying to do is specify the PageSize (ie the number of rows shown on a page) of the grid by calculating the maximum number of rows that can be shown without scrolling. I think I can make this calculation client-side by determining the grid data height (using the grid.GridDataDiv.style.height property) and estimating the height of each row. That gives me the number of rows which are visible w/o scrolling, and I'd like to set the pageSize to this value (or perhaps one less than this value). So, assuming I am able to make this calculation and get the appropriate page size, the challenge becomes how do I set the grid's pageSize property from client-side code prior to the loading the grid data.
0
Hello Albert,
RadGrid's page size can be set on the client only when client binding is used, otherwise a change of the pagesize would require a postback. For a live example of client-side bound grid you can refer to the link below::
http://demos.telerik.com/aspnet-ajax/grid/examples/client/declarativedatabinding/defaultcs.aspx
And more information about how to change the grid page size using client side api is available in the help article below:
http://www.telerik.com/help/aspnet-ajax/grid-gridtableview-set-pagesize.html
Kind regards,
Pavlina
the Telerik team
RadGrid's page size can be set on the client only when client binding is used, otherwise a change of the pagesize would require a postback. For a live example of client-side bound grid you can refer to the link below::
http://demos.telerik.com/aspnet-ajax/grid/examples/client/declarativedatabinding/defaultcs.aspx
And more information about how to change the grid page size using client side api is available in the help article below:
http://www.telerik.com/help/aspnet-ajax/grid-gridtableview-set-pagesize.html
Kind regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 13 Jan 2012, 03:34 PM
so is there no way to change the page size client-side during the initial page loading or initializations... also is there no way to determine what the page size should be and then change the page size client-side using an ajax update?
0
Hi,
I think that help article linked below will help you to achieve your goal:
http://www.telerik.com/help/aspnet-ajax/grid-resize-grid-with-scrolling-when-less-data.html
Regards,
Pavlina
the Telerik team
I think that help article linked below will help you to achieve your goal:
http://www.telerik.com/help/aspnet-ajax/grid-resize-grid-with-scrolling-when-less-data.html
Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 19 Jan 2012, 01:49 AM
I'm not sure how that article helps. I am not looking to resize the grid or change its scroll height or anything like that (the scroll height should always be 100%).
Perhaps I'm not sure I'm explaining my scenario properly. I have a grid that gets displayed in vairious sized containers (it is part of a user control that is used in different places). If I set the grid Page Size, say to 20 records, then in some of these containers, scrolling is required and in others it is not. I would like to be able to set the Page Size to a value which is apprpirate for the particular container the grid is being displayed in so that scrolling is not needed. For example, in the larger container scenario, I can set the pages size to 30 records. In the smaller container, I can set it to 15 records. I am aware that if the container size is changed (like if it is 100% height and the window is resized) then scrolling may become necessary. However, I am not concerned about the situation where the container is resized. I am only interested in the initial display of the grid. When a particular page loads, I can calculate the height avalable to the grid data by using the container height and I can estimate the height of each row in the grid. In that way I can estimate the number of rows which should be visible without scrolling and it would be great if I could somehow set the Grid PageSize property. All of this would ideally occur when the page loads and of course, before the grid is bound.
Perhaps I'm not sure I'm explaining my scenario properly. I have a grid that gets displayed in vairious sized containers (it is part of a user control that is used in different places). If I set the grid Page Size, say to 20 records, then in some of these containers, scrolling is required and in others it is not. I would like to be able to set the Page Size to a value which is apprpirate for the particular container the grid is being displayed in so that scrolling is not needed. For example, in the larger container scenario, I can set the pages size to 30 records. In the smaller container, I can set it to 15 records. I am aware that if the container size is changed (like if it is 100% height and the window is resized) then scrolling may become necessary. However, I am not concerned about the situation where the container is resized. I am only interested in the initial display of the grid. When a particular page loads, I can calculate the height avalable to the grid data by using the container height and I can estimate the height of each row in the grid. In that way I can estimate the number of rows which should be visible without scrolling and it would be great if I could somehow set the Grid PageSize property. All of this would ideally occur when the page loads and of course, before the grid is bound.
0
Hello Albert,
You can use the following online integration demo of our grid/splitter controls as a basis for your custom implementation:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandsplitterresizing/defaultvb.aspx?product=grid
Review the code under the ASPX /C#/ VB.NET tabs which can give you a better idea about how to increase/decrease the number of grid records on pane resizing.
I hope this will gets you started properly.
All the best,
Pavlina
the Telerik team
You can use the following online integration demo of our grid/splitter controls as a basis for your custom implementation:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandsplitterresizing/defaultvb.aspx?product=grid
Review the code under the ASPX /C#/ VB.NET tabs which can give you a better idea about how to increase/decrease the number of grid records on pane resizing.
I hope this will gets you started properly.
All the best,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now