jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Keeping grid's height fixed, once adjusted by autoheight:true
Tagged: jquery grid plugin
This topic contains 11 replies, has 2 voices, and was last updated by Marc 10 years, 10 months ago.
-
Author
-
Hi,
[Expected feature]
I would like to keep a grid’s height fixed, once it has been adjusted to its size.
The reason is I find it a bit user unfriendly to have the pager moving up and down, depending on being on the last page or the previous ones.[Attempt]
I was expecting the following workaround to work:- First let the grid adjust its size automatically with autoheight:true
- Then, using the initialized event, or the rendered property, disable autoheight. If not enough, manually set the grid’s height to the value it had before disabling autoheight
[Problem statement]
However, it did not work. The height is set to a defaut of 400, whatever the autoheight value was.
This fiddle shows the result.[Question]
Is there a way to get the actual grid’s height, when it has been set automatically (autoheight:true) ?
If not, is there another way to freeze the height once it has been adjusted by autoheight ? Certainly, the code can compute <header height> + n x <row height> + <pager height>, since my grid is simple (eg. no variable height rows, no rows details…), but it would obviously be more efficient to reuse the value computed by the grid – don’t recode what already exists.[Additional note]
I’m aware that the height would then have to be readjusted each time the page size changes, but then the pagesizechanged event could certainly be used to fix it.Thanks for your help.
Best regards.
Marc.
Hi Marc,
You should choose for your app whether to have fixed height or whether to set autoheight property. You cannot combine both of these.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Thank you, I understand it is not a supported feature.
Is it possible then to include to the grid’s wish list any mechanism that would prevent the pager to jump up and down, when the user navigates between pages ?
Thanks and best regards.
Marc.
Hi Marc,
It would jump up/dopwn if you’ve enabled autorowheight and autoheight. If you use fixed height for your Grid, the Pager would not move.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Pete,
Sure, I agree. But with fixed height, is there a way that, except for the last page, the grid’s height is set to exactly its actual height, with no extra space ? That’s my point : I can’t figure out how to achieve this. At least simply, without recomputing manually the sum of the height of all grid’s elements (header, row, footer…).
Am I missing something ?
Thank you.
Hi again,
Thinking again about this discussion, I think there is an information I omitted to mention. The grid that I’m thinking of is meant to be kept very simple, just like in the fiddle I referred to above :
- Header always présent, fixed height
- Fixed height rows : one single line of text per row
- Pager (footer) always present, fixed height
The only variation may be a change in the number of rows per page, which can be trapped, as I said, through the pagesizechanged event .
Therefore, I really need to have a fixed height grid. The only concern is : how do I get rid of the unelegant orange area between the last line and the footer, that is displayed in the fiddle ?
Does that make my question easier to understand ?
Thanks and best regards.
. . . last note, about the following sentence in my previous post :
[…] how do I get rid of the unelegant orange area […]
Please note, obviously, the orange area would still be acceptable for the last page (and only this one), in order to keep the height fixed, and therefore the pager always at its same place.
Hi Marc,
By setting the Grid’s height property, you can choose the best height for your scenario.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter,
Sure, I have no problem with :
$('#myGrid').jqxGrid({ height: someValue });
The question is : how (and incidentally where in the code ?) do I get the correct height value (someValue in the above snippet) ? Given :
- a theme
- a single header + ten single-line rows + 1 footer
how do I determine the resulting height ?
Thank you Pete, and sorry if it is a bit difficult, for me to explain the question, and for readers to understand it.
Brgds.
HI Marc,
The rowsheight is a fixed value, the columnsheight, the pager’s height, the statusbar’s height, groups header and toolbar’s height are all with fixed values. You can easily calculate the best height property value for your scenario. You can check the documentation API about rowsheight, pagerheight, columnsheight, toolbarheight, statusbarheight and groupsheaderheight properties.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Pete,
Thank you for the answer. As said in my initial post :
Certainly, my code can compute <header height> + n x <row height> + <pager height>, since my grid is simple (eg. no variable height rows, no rows details…), but it would obviously be more efficient to reuse the value computed by the grid – don’t recode what already exists.
and since the grid itself has to compute its own total height, I was wondering if I could get the grid’s computed value, rather than re-computing it myself.
You confirm that it is not possible, thank you. Even if not necessarily my prefered one, it’s an answer anyway. “Dura lex sed lex” (Law is tough, but that’s law)
Best regards
Hi,
In fact, it does not work exactly as expected. In this fiddle, which doesn’t quite work, the height is computed like this :
function gridHeight() { return columnsHeight + pageSize * rowsHeight + pagerHeight; };
A minor fix is required, as demonstrated by this almost identical fiddle. The fix is :
function gridHeight() { return columnsHeight + pageSize * rowsHeight + pagerHeight + 4; };
Any idea why ?
Anyway, the code does the trick. It even works when the page size is changed.
Except, to be quite complete, that the offset depends on the theme. For the “Orange” theme, for example, the required offset (the minimal value that works) is 2, not 4. Has to do with the borders size, maybe ? Weird…Best regards.
-
AuthorPosts
You must be logged in to reply to this topic.