ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: queensgambit9 on January 16, 2023, 12:46:24 am
-
Hi
I would like to clear filter (if exists) on a column when it changes from visible to hidden.
I used this before: https://paramquery.com/forum/index.php?topic=2355
Now using 8.7.0 with updated show / hide functionality how could it be implemented?
-
hideCols event can be used for this.
hideCols: function(evt, ui){
var grid = this;
ui.diHide.forEach(function(di){
var col = grid.getColumn({dataIndx: di});
if(col.filter && col.filter.crules){
col.filter.crules.forEach(function(rule){
rule.value = undefined; //clear the values while keep the filter conditions.
rule.value2 = undefined;
});
}
});
grid.filter();//refresh filter.
},
-
Thanks, works fine.
-
By the way I would like to clear/refresh filter only if filter was set to avoid unnecessary call to db...what would be a good way to do this?
-
did like this:
if (rule.value != undefined || rule.value2 != undefined) {
rule.value = undefined; //clear the values while keep the filter conditions.
rule.value2 = undefined;
grid.filter();//refresh filter.
}
or is there a better way?
-
hideCols: function(evt, ui){
var grid = this, requireRefresh;
ui.diHide.forEach(function(di){
var col = grid.getColumn({dataIndx: di});
if(col.filter && col.filter.crules){
col.filter.crules.forEach(function(rule){
if (rule.value != undefined || rule.value2 != undefined) {
requireRefresh = true;
rule.value = rule.value2 = undefined; //clear the values while keep the filter conditions.
}
});
}
});
if( requireRefresh ) grid.filter();//refresh filter.
},