如何在免费jqgrid

时间:2016-03-01 21:08:11

标签: javascript jquery css jqgrid free-jqgrid

在最新的免费jqgrid中,textarea用于内联和表单编辑。 在内联编辑列宽度应为350px。这在colmodel中指定并且工作正常。

如何在350px以上的表格编辑中增加textarea宽度,使其占用表单编辑窗口中的整个编辑列或具有更大的硬编码宽度? 我试图在模板中使用类属性来仅在表单编辑中添加类,但是类没有添加到textarea。

Colmodel:

{"template":MultiLineTemplate,
"name":"Avaldis",
"editoptions":{
  "class":"",
  "readonly":null
  },
"editrules":{"edithidden":true},
"editable":function(options){return getEditable(options,false);}
,"width":350
}

colmodel中使用的javascript:

var multilinePrefix = '<div class="jqgrid-multiline-cell">';
var MultiLineTemplate = {
    edittype: "textarea",
    searchoptions: { sopt: ["cn", "nc"] },
    formatter: function (v) {
        return multilinePrefix + (v == null ? '' : $.jgrid.htmlEncode(v)) + '</div>';
    },

    unformat: function (cellvalue) {
        return cellvalue;
    },

    editoptions: 
    {
        rows: 3,
        wrap: "off",
        style: 'overflow-x: hidden',
    }
};


function getEditable(options, isReadonly) {
    if (!isReadonly) {
        return true;
    }
    if (options.mode === "cell" || options.mode === "add" || options.mode === "edit") {
        return true;
    }
    return "readonly";
}

式:

.jqgrid-multiline-cell {
    max-height: 2.8em;
    overflow-x: hidden;
}

问题how to restrict jqgrid textarea height in grid only与此有些相关。

1 个答案:

答案 0 :(得分:3)

我认为你可以通过添加cols: 20的{​​{1}}属性来解决问题:

editoptions

到具有editoptions: { cols: 20 }

的列
相关问题