问题
I'm having a grid, and I also applied the (autoResizable: true
) on each column. Now I don't want the grid itself to shrink/widen whenever I double click to resize the column. I want the grid itself to stay as is.
I read about setColWidth
new function, but failed to use it.
An example will be great.
Also,
Is there any changes to the setGridWidth
implementation? I have two grids one below the other, and it appears that there is some calculation of the grid width AFTER my call is being made:
For example, each time I execute the following:
$(nameOfGrid).jqGrid('setGridWidth', $('.ui-layout-center').width() - 10, true);
After the above call, both of the grid are effected, but the upper grid is shorter a bit from the lower (or vise versa), so I wonder if there is some calculation INSIDE the setGridWidth
that effect the overall experience.
回答1:
You wrote "I don't want the grid itself to shrink/widen whenever I double click to resize the column". On the other side you wrote: "I also applied the (autoResizable: true) on each column". The property autoResizable: true
in the column means nothing more that you want that the column will be auto-resizable and the double click on the resize of the column will change the column width to the optimal value. So if you don't want that some column will be auto-risizable you should remove autoResizable: true
property.
One more option which one have in free jqGrid 4.8 is the usage of resizeDblClick
callback or event jqGridResizeDblClick described in the readme here. You can use resizeDblClick
callback for example which return false
. It will prevent resizing of column on double-click on the column resizer. The options of the callback are iColIndex
and cm
which allows to make return value depend on the columns.
The method setColWidth
was originally introduced in the answer. It contains the demo. One more demo use the method as plugin published on github. The same options have setColWidth
of free jqGrid 4.8, but the implementation is a little other.
The last problems with setGridWidth
are not full clear for me. I recommend you always to create short demo which reproduce the problem. In the case I could find the reason of the problem very quickly and I could suggest either the changes of your code or I could fix the bug in free jqGrid. If you just describe that you have a demo which works incorrectly help me not. In any way I would suggest you to save $('.ui-layout-center').width()
value in a variable and to call setGridWidth
with the same value for two grids which you use.
来源:https://stackoverflow.com/questions/29062937/jqgrid-4-8-0-use-of-the-new-width-size