停止在jqgrid中可调整大小的列 [英] Stopping columns resizable in jqgrid

查看:180
本文介绍了停止在jqgrid中可调整大小的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使jqgrid的所有列不可调整大小?目前,我认为我必须指定属性{resizable:false}的每一列.无论如何,我可以为整个网格指定内容吗?

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?

推荐答案

从版本3.8.2开始,jqGrid支持一项非常有用的功能:列模板. (我称赞此功能可能不太正确,因为该功能是在

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.

我将在一个示例中对其进行解释.如果您定义其他jqGrid参数

I explain it on an example. If you define additional jqGrid parameter

cmTemplate:{resizable:false}

那么您的问题就会解决.

then your problem will be solved.

如果您具有colModel项的所有列中共有的更多属性,例如align:'center',则cmTemplate也将为您提供帮助(cmTemplate:{resizable:false,align: '中央'}).在jqGrid 3.8.2中,

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.

用法jqGrid列模板的另一个版本为:

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},
        ...
    ]
    ...
});

通过这种方式,您可以定义一些模板(例如myDateTemplate),并在网格中的许多位置(或gid)中使用它们.就此功能而言,您可以使代码更短,更易读且易于更改.

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.

这篇关于停止在jqgrid中可调整大小的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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