0

I am using jqGrid in various places throughout a web app. I want to use specified column widths (which I don't want to be changed to avoid wrapping/text cut off) and if the total of the column widths for a particular grid goes over the page width I want a scroll bar to appear on the grid, not on the page. Is this possible with jqGrid options, or would some extra javascript be required as I haven't been able to get this behaviour.

4

2 回答 2

2

您可以通过设置它的宽度选项来限制网格的宽度(还要记住您需要shrinkToFit: false在选项中设置),例如:

$('#gridId').jqGrid({
    ...
    shrinkToFit: false,
    width: $(document).width()
});

这也可以通过以下方法动态更改(例如在页面调整大小时)setGridWidth

$('#gridId').jqGrid('setGridWidth', $(document).width())
于 2012-11-19T10:33:49.627 回答
0

我不确定我是否理解您的更正:有很多意见是设置网格宽度的最佳方法。

一般来说shrinkToFit: falsewidth如果你想拥有像你在colModel. 如果您不希望用户能够在列标题之间的分区的拖放方面更改列宽,则可以对某些列使用fixed: true属性。

此外,我建议您阅读另一个答案,其中我描述了如何修改 jqGrid 的代码,以便在用户调整列大小后调整网格的总宽度。我不确定您是否想要这种行为。我个人使用这种方法。

于 2012-11-19T10:30:49.860 回答