Forum


22:59

30/03/2009

Hi,
I have two grids on a page: gridA and gridB, both height: 200 and visible onload. What I like it to do are:
1) At least one grid must be shown at any time.
2) If one grid is hidden, the height of the other is doubled to cover the space given up.
Steps to reproduce the only problem encountered:
1) Hide gridA -> gridA is hidden, gridB height: 400
2) Hide gridB -> gridB is hidden, gridA height: 400
3) Unhide gridB -> gridA height: 200, gridB height: still 400!
OR
1) Hide gridB -> gridB is hidden, gridA height: 400
2) Hide gridA -> gridA is hidden, gridB height: 400
3) Unhide gridA -> gridB height: 200, gridA height: still 400!
Have I missed anything? The following function is called in onHeaderClick for both grids. sourceGrid is the grid where header is clicked, targetGrid is the other grid.
function setGridHeight(sourceGrid, sourceGridState, targetGrid){
if(sourceGridState == “hidden”){
sourceGrid.jqGrid('setGridHeight', 200); // Not working!
// Grid#1 is hidden, increase height of grid#2 and unhide it if needed.
targetGrid.jqGrid('setGridHeight', 400);
if(targetGrid.jqGrid('getGridParam', 'gridstate') == “hidden”)
targetGrid.jqGrid('setGridState', “visible”);
}
else{
// Unhide grid#1, reset height of both grids.
sourceGrid.jqGrid('setGridHeight', 200); // Not working!
targetGrid.jqGrid('setGridHeight', 200);
}
}
Please advise.. Thank you!!
11:12

Moderators
30/10/2007

Hello,
Making alerts after if and else will give you the answer.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
12:07

Moderators
30/10/2007

Hello,
My thoght was not only this, but how you pass the sourceGrid, targetGrid - are they passed correct to the function?
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
20:40

30/03/2009

I think so since I do see grid height changes. The only cases where they do not work as expected are described in my first post. It works when you click to hide a grid but not when click to unhide, the unhidden grid height remains at 400 when viewed even though .jqGrid('getGridParam', 'height') reports 200.
gridA event -
onHeaderClick: function(stat){
setGridHeight($("#gridA"), stat, $("#gridB"));},
gridB event -
onHeaderClick: function(stat){
setGridHeight($("#gridB"), stat, $("#gridA"));},
04:48

Moderators
30/10/2007

Hello,
Really forgot it, but you will need to use setTimeout to the grids that do not work.
This is connected maybe with this that the hidden element in jQuery has width and height = 0;
Regrads
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
68 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66