How I can make all the columns of jqgrid not resizable? Currently I think every column I've to specify the property { resizable:false }. Is there anyway I can specify for the entire grid?
Starting with version 3.8.2 jqGrid supports one very useful feature: column templates. (It's probably not quite correct from me to praise the feature because the feature was introduced on my own suggestion :-)). The feature is still not really documented, but it can be used very easily.
I explain it on an example. If you define additional jqGrid parameter
cmTemplate:{resizable:false}
then your problem will be solved.
If you have more properties which are common in all columns of colModel
items, for example align:'center'
the cmTemplate
will help you also (cmTemplate:{resizable:false, align:'center'}). In jqGrid 3.8.2 was small bug in priority of template settings relatively to settings from colModel
, but the bug is fixed in jqGrid 4.0.0. So the properties from cmTemplate
can be interpret just as default values for colModel
items.
One more version of usage jqGrid column template is in the form:
var myDateTemplate = {sorttype:'date', formatter:'date',
formatoptions: {newformat:'m/d/Y'}, datefmt: 'm/d/Y',
align:'center', width:80 }
$("list").jqGrid({
colModel: [
...
{name:'column1': template:myDateTemplate},
{name:'column2': template:myDateTemplate, width:90},
...
]
...
});
In the way you can define some templates (like myDateTemplate
) and use there in many places in your grid (or gids). With respect of the feature you can make your code shorter, better readable and easily changeable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With