0

I use jqgrid at my page. I wanted to have fixed height at it (Users should scroll down if there is more rows). It works for tables which has many rows. However even table row size is not much there is a place for scroll bar (number 2 at image) and there is an extra line at left (number 1 at image). This is same for each table. Here is an example of my tables:

enter image description here

I used that at my options:

...
height: '150'
jsonReader: {
        repeatitems: false
},
loadui:         'disable',
altRows:        true,
viewrecords:    true,
loadonce:       true,
...

and did not do anything special to height.

Any ideas?

kamaci
  • 72,915
  • 69
  • 228
  • 366

1 Answers1

0

You don't posted any details about how you use jqGrid. So I can suppose that you use height option with some integer value. If you would use height: "auto" or height: "100%" then you would not have the described problem. I personally use almost always height: "auto" and specify the maximal grid width by usage rowNum value.

jqGrid calculate the width of the grid based on the total width of all columns. If the value of height option is neither "auto" nor "100%" it adds additional space to hold possible vertical scroll bar. You can use scrollOffset: 0 option to remove unneeded space of the right size of the grid. Alternatively you can call setGridWidth and setGridHeight methods to set width and height of the grid explicitly on any other value which you want.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Yes, I've set an integer number for height property. My customer does not want a pagination bar. `height: "auto"` and setting rowNum is not a solution for my current situation as I described. Because it only show limited number of rows. I want to see all off them but i.e. 5 rows will be at table and the others will be seen bu scrolling the var. PS: I've edited my question. – kamaci Oct 13 '14 at 11:13
  • @kamaci: I can't speak about the "solution for my current situation" because you didn't described your full scenario. If you don't want to use local pagination of data you *have to* set `rowNum` to some large enough value (`rowNum: 100000` for example). If you don'u do this then jqGrid will displays only first 20 rows of results (the default value of `rowNum`). If you are sure that you have 5 rows or less then you will have grid with not large enough height and all will looks OK. You can consider to use `max-height` additionally (see [the answer](http://stackoverflow.com/a/5896432/315935)). – Oleg Oct 13 '14 at 11:18
  • I found the reason. i.e. when I set height to 100 px. and if table has many rows and so height is greater than 100 px. everything is OK (when I use `scrollOffset: 0`) However i.e. if table is 50 px. `ui-jqgrid-bdiv` has a border-left property which has 100px. height. This causes problem number one. Do you have any idea how to fix it? If it is not clear I will my question again. – kamaci Oct 13 '14 at 11:42
  • Maybe setting grid ui-jqgrid-bdiv's height to table's height if height is less than an a size? – kamaci Oct 13 '14 at 11:45
  • @kamaci: Sorry, but I can't follow you. Could you exactly describe which settings you use now and which problem you still have. I don't recommend you to set `height` of bdiv or some other internal divs if you don't know exactly the meaning of all the divs (see [here](http://stackoverflow.com/a/3463002/315935) for description of the main divs). I still don't understand your full scenario. Probably you need to call `setGridHeight` inside of `loadComplete` in your case (you can test the current number of loaded rows). – Oleg Oct 13 '14 at 11:51