Reputation: 153
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.
Upvotes: 0
Views: 1741
Reputation: 24125
You can limit the width of the grid by setting it's width option (also remember you need to set shrinkToFit: false
in your options), for example:
$('#gridId').jqGrid({
...
shrinkToFit: false,
width: $(document).width()
});
This can also be changed dynamically (for example on page resize) with setGridWidth
method:
$('#gridId').jqGrid('setGridWidth', $(document).width())
Upvotes: 2
Reputation: 221997
I am not sure that I understand you corrects: there are many opinions what is the best way to set the width of the grid.
In general you should use shrinkToFit: false
and not use and width
option of jqGrid if you want to have exact widths of columns like you specified in colModel
. You can use fixed: true property for some columns if you don't want that the user be able to change the column width with respect of drop&drag of the partition between of the column header.
Additionally I recommend you to read another answer where I describe how one can modify the code of jqGrid so that the total width of the grid would be adjusted after the user resize the column. I am not sure that you want exactly the behavior. I personally use this approach.
Upvotes: 0