ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: queensgambit9 on June 08, 2016, 02:00:23 pm
-
Hi
Trying to creatte button to clear filters with code:
{ type: 'button', label: 'Clear Filters', listeners: [
{
"click": function (evt, ui) {
var CM = $grid.pqGrid.getColModel();
for(var i=0, len = CM.length; i < len; i++){
var column = CM[i];
if(column.filter){
column.filter.value = null;
column.filter.cache = null;
}
}
$grid.pqGrid.refreshHeader();
$grid.pqGrid.filter({
oper: 'replace',
data: []
});
}
}
]
}
but get error: Uncaught TypeError: $grid.pqGrid.getColModel is not a function...
-
That's incorrect syntax to call methods.
Instead of $grid.pqGrid.getColModel(), please try this: $grid.pqGrid( "getColModel" );
-
Thanks. Modified code:
{ type: 'button', label: 'Clear Filters', listeners: [
{
"click": function (evt, ui) {
var CM = $grid.pqGrid( "getColModel" );
for(var i=0, len = CM.length; i < len; i++){
var column = CM[i];
if(column.filter){
column.filter.value = null;
column.filter.cache = null;
}
}
$grid.pqGrid( "refreshHeader" );
$grid.pqGrid( "filter" );({
oper: 'replace',
data: []
});
}
}
]
}
now gives: "Uncaught TypeError: Cannot read property 'apply' of undefined"...
-
Filter method call is incorrect.
$grid.pqGrid( "filter" );({
oper: 'replace',
data: []
});
Please correct it:
$grid.pqGrid( "filter", {
oper: 'replace',
data: []
});