jqgrid中的预选过滤器(多选) [英] Pre-select filters in jqgrid (multi-select)
问题描述
以此示例为例( http://www.ok-soft-gmbh .com/jqGrid/SimpleLocalGridWithSearchingToolbarMultilpe.htm )( Excel像在jqgrid中进行过滤一样)
是否有从头开始设置过滤器参数的方法?例如,在通过...发货"列中,我希望选中"TNT"和"Intim",而未选中"FedEx".
我认为可行的一种解决方案是ship_via
if(id == 'gs_ship_via'){
_.forEach($options, function(option){
if(option.value != 'FexEx'){
option.selected = true;
} else {
option.selected = false;
}
});
}
此后,我遇到的问题是它不会更新网格中的数据.因此,在加载复选框后,我需要一种不同的方式来设置复选框,以更新网格的方式.
我假设您需要包括change
事件($("#gs_ship_via").change();
)的触发器或调用triggerToolbar
($grid[0].triggerToolbar();
)的触发器.确切的解决方案可能在很大程度上取决于您进行更改的位置.如果要在初始化多重选择后对例如 的多重选择选项进行更改,则可能会看到错误的多重选择选项,并且可能需要调用refresh
.
请参见该演示,其显示的结果类似于
可能可以修改解决方案来设置多个值,使用答案中的想法,但与目前相比,这需要花费更多时间. :-(
Taking this example (http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGridWithSearchingToolbarMultilpe.htm) from this question (Excel like filtering in jqgrid)
Is there a way to set the filter parameters from the start? For example, in the 'Shipped via' column, I would want 'TNT' and 'Intim' to be checked, leaving 'FedEx' unchecked.
One solution I thought was viable is to ship_via
if(id == 'gs_ship_via'){
_.forEach($options, function(option){
if(option.value != 'FexEx'){
option.selected = true;
} else {
option.selected = false;
}
});
}
The problem I run into after that is that it doesn't update the data in the grid. So, I need a different way to set the check box after it's loaded in a way that will update the grid.
I suppose that you need to include trigger of change
event ($("#gs_ship_via").change();
) or to call triggerToolbar
($grid[0].triggerToolbar();
). The exact solution can heavy depend on the place where you made the changes. If you would make the changes of multi-select options for example after initializing of multiselect you could see wrong multiselect options and you could require to call refresh
.
See the demo which displays the results like
Probably one can modify the solution for setting multiple values which uses the idea from the answer, but it will take a little more time as I have currently. :-(
这篇关于jqgrid中的预选过滤器(多选)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!