JQGrid列自动宽度 [英] JQGrid Column auto width

查看:627
本文介绍了JQGrid列自动宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道如何将jqGrid列宽设置为auto?

I am just wondering how can we set a jqGrid column width to auto?

...
colModel: [
{ name: 'MyDescription', index: 'description', align: 'left', width: 150, sortable: false },
...

对于上述声明,我如何为列指定自动宽度,以使其适合其中最大内容的大小.

for the above statement how can I specify an auto width for the column so that it fits to the size of the maximum content in it.

推荐答案

无法在jqGrid中指定自动宽度列.但是,您可以将网格的rinkleToFit选项设置为true并设置一些近似的宽度值(例如20、20、20、80),并且列的宽度将缩放为网格的宽度.

There are no way to specify autowidth column in jqGrid. But you can use shrinkToFit option of a grid set to true and set some approximate width values (e.g. 20, 20, 20, 80) and width of columns will be scaled to width of a grid.

shrinkToFit:

shrinkToFit:

此选项描述了针对每一列的初始宽度和网格宽度的计算类型.如果该值为true且设置了width中的值选项,则:根据定义的选项宽度缩放每个列的宽度.示例:如果我们定义两个宽度分别为80和120像素的列,但希望网格具有300像素-则按以下方式重新计算这些列:1-列= 300(新宽度)/200(所有宽度的总和) )* 80(列宽)= 120,第二列= 300/200 * 120 =180.网格宽度为300px.如果值为false且设置了width选项中的值,则:网格的宽度为option中设置的宽度.列宽不会重新计算,并且具有colModel中定义的值.

This option describes the type of calculation of the initial width of each column against with the width of the grid. If the value is true and the value in width option is set then: Every column width is scaled according to the defined option width. Example: if we define two columns with a width of 80 and 120 pixels, but want the grid to have a 300 pixels - then the columns are recalculated as follow: 1- column = 300(new width)/200(sum of all width)*80(column width) = 120 and 2 column = 300/200*120 = 180. The grid width is 300px. If the value is false and the value in width option is set then: The width of the grid is the width set in option. The column width are not recalculated and have the values defined in colModel.

这篇关于JQGrid列自动宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆