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.
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:
You can use the method
setGridWidth
.Example:
DEMO
This is mostly working for me.
You can try to use tableToGrid, as far as I remember it does preserve widths. If so, you can also look into its source code if its behaviour doesn't fully suit your needs.