免费JqGrid - 搜索过滤器的宽度

时间:2017-05-17 07:23:03

标签: jqgrid

我正在使用免费的JqGrid,我遇到的问题是搜索过滤器字段不会延长以适应列的宽度,正如您在下面的标题中看到的那样。我该如何实现这一目标? enter image description here

网格由以下代码创建;

$(function () {
    getGrid();
});

var populateGrid = function (data) {
    var grid = $("#grid");
    grid.jqGrid({
        data: data,
        colNames: ["Contract No", "Title", ""],
        colModel: [
            { name: "FullContractNo", label: "FullContractNo", width: 80, align: "center" },
            { name: "ContractTitle", label: "ContractTitle", width: 500, searchoptions: { sopt: ["cn"] } },
            { name: "Link", label: "Link", width: 60, search: false, align: "center" }
        ],
        cmTemplate: { autoResizable: true },
        rowNum: 20,
        pager: "#pager",
        shrinkToFit: true,
        rownumbers: true,
        sortname: "FullContractNo",
        viewrecords: true
    });

    grid.jqGrid("filterToolbar", {
        beforeSearch: function () {
            return false; // allow filtering
        }
    }).jqGrid("gridResize");
    $("#divLoading").hide();
}

var getGrid = function () {
    var url = GetHiddenField("sir-get-selected-contract-list");
    var callback = populateGrid;
    dataService.getList(url, callback);
}

1 个答案:

答案 0 :(得分:1)

设置搜索字段宽度的最简单方法是使用attr的{​​{1}}属性:

searchoptions

可以在搜索字段中设置任何属性,包含{ name: "ContractTitle", label: "ContractTitle", width: 500, searchoptions: { sopt: ["cn"], attr: { style: "width:100px;" } } } 属性。