0

我需要根据列宽动态增加 jqgrid 搜索框的宽度。

我试图在内部beforeshowsearch事件中做到这一点。它似乎没有任何效果。

4

1 回答 1

3

您可以使用beforeShowSearch(!!! not beforeshowsearch) 在搜索对话框中进行更改。有关代码示例,请参见此处(如果您使用最新版本的 jqGrid ,则可以使用this.id而不是)。grid[0].id我建议您另外使用recreateFilter: true搜索选项。

通过navGrid将“搜索”按钮添加到导航栏的方式,在每次调用创建网格的方法时使用参数width属性。因此,如果您保留并更改下一个搜索对话框将使用新的宽度值:prmSearchsearchGridprmSearchwidth

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
于 2013-01-21T14:17:20.567 回答