我需要根据列宽动态增加 jqgrid 搜索框的宽度。
我试图在内部beforeshowsearch
事件中做到这一点。它似乎没有任何效果。
您可以使用beforeShowSearch
(!!! not beforeshowsearch
) 在搜索对话框中进行更改。有关代码示例,请参见此处(如果您使用最新版本的 jqGrid ,则可以使用this.id
而不是)。grid[0].id
我建议您另外使用recreateFilter: true
搜索选项。
通过navGrid
将“搜索”按钮添加到导航栏的方式,在每次调用创建网格的方法时使用参数width
属性。因此,如果您保留并更改下一个搜索对话框将使用新的宽度值:prmSearch
searchGrid
prmSearch
width
var pSearch = {
recreateFilter: true,
multipleSearch:true,
width: 500
};
$("#list").jqGrid({...}); // create the grid
$("#list").jqGrid("navGrid", "#pager", {}, {}, {}, {}, pSearch);
// if the user opens searching dialog now the width 500 will be used
...
pSearch.width = 800;
// if the user opens searching dialog now the new width 800 will be used