Resize jqGrid based on number of rows? - Grid height?

浪尽此生 提交于 2020-01-01 16:48:07

问题


I have the same problem as detailed in the post Resize jqGrid based on number of rows?

Some of the suggestions (which seem totally logical) do not work because when I try to get the height of the grid using var height = $("#TableId").height(); it returns what was set when setting up the grid, i.e. "100%"...

How do I get the height in pixels?


回答1:


It was something wrong in your previous experiments. How you can see from the demo the jQuery.height method get you the height of the grid in pixel if you use height:'100%' or height:'auto' in the jqGrid definition.

By the way if you want to know the full grid height including the capture, headers, pager and so on you should get hight of $("#gbox_TableId").height() instead of $("#TableId").height().




回答2:


Jqgrid creates a lot of extra markup wrapping your initial table. So, to change its height, you can do this:

$("#TableId").closest(".ui-jqgrid-bdiv").height(200);

Hope this helps. Cheers




回答3:


Simple use
$('.ui-jqgrid-bdiv').css('height', '100%');


来源:https://stackoverflow.com/questions/5870057/resize-jqgrid-based-on-number-of-rows-grid-height

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!