Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
203 views
in Technique[技术] by (71.8m points)

jquery - jqGrid 4.8.0 - Use of the new width size

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...