如何在免费的jqgrid中增加表单编辑中的文本区域宽度

How to increase textarea width in form edit in free jqgrid

本文关键字:文本 编辑 区域 表单 增加 免费 jqgrid      更新时间:2023-09-26

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

如何在表单编辑中增加文本区域宽度超过 350px,使其占据表单编辑窗口中的整个编辑列或具有更大的硬编码宽度?我尝试在模板中使用类属性仅在表单编辑中添加类,但类未添加到文本区域。

合作模型:

{"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;
}

问题如何仅限制网格中的jqgrid文本区域高度与此有关。

我想

你可以通过添加editoptions的属性cols: 20来解决问题:

editoptions: { cols: 20 }

到具有edittype: "textarea"的列。