Reputation: 1251
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.
Upvotes: 1
Views: 1328
Reputation: 221997
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. :-(
Upvotes: 1