我正在使用免费的JqGrid,我遇到的问题是搜索过滤器字段不会延长以适应列的宽度,正如您在下面的标题中看到的那样。我该如何实现这一目标?
网格由以下代码创建;
$(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);
}
答案 0 :(得分:1)
设置搜索字段宽度的最简单方法是使用attr
的{{1}}属性:
searchoptions
可以在搜索字段中设置任何属性,包含{
name: "ContractTitle",
label: "ContractTitle",
width: 500,
searchoptions: {
sopt: ["cn"],
attr: { style: "width:100px;" }
}
}
属性。