ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: przemek on January 07, 2015, 06:40:00 pm
-
Hello,
I'm trying to prepare SELECT options for remote filtering and i don't know how to do it.
This is column in colModel:
{
title: "Active",
dataIndx: "Active",
filter:{
prepend: { '': 'Select' },
type: 'select',
attr: 'single',
condition: 'equal',
listeners: ['change'],
value: ['xxx', 'yyy']
}
},
I would like to have "xxx" and "yyy" in select options in filter header but it don't works.
Please tell me how can i do it.
-
That would be options.
{
title: "Active",
dataIndx: "Active",
filter:{
type: 'select',
condition: 'equal',
listeners: ['change'],
options: ['xxx', 'yyy']
}
},
http://paramquery.com/pro/api#option-column-filter
-
Great, thanks!
Is there any way to get options from server ?
-
yes options could be fetched from server via $.ajax and bound later on in success callback
var column = $grid.pqGrid("getColumn", { dataIndx: "ShipRegion" }),
filter = column.filter;
filter.cache = null;
filter.options = [ new options ];
$( '.selector' ).pqGrid("refresh");
Similar Example on late binding of options:
http://paramquery.com/pro/demos/filter_header
-
Thanks again, it works!
Another question in this topic is about pagination.
I have noticed that when i select NO, i go to second results page and change to YES i don't see any results because i have results with YES only on 1 page.
-
Please check the server code in demo for remote paging, you need to recalculate the current page i.e., $pq_curPage where $total_Records would be the number of filtered records.
$skip = ($pq_rPP * ($pq_curPage - 1));
if ($skip >= $total_Records)
{
$pq_curPage = ceil($total_Records / $pq_rPP);
$skip = ($pq_rPP * ($pq_curPage - 1));
}
-
Hello, thanks for your help!
I have another question about optgroup in select filter.
How should prepare connection between group and elements which i'll get using ajax...
I would like to do something like in paramquery example but using remote data:
Continent
- country
- country
Continent
- country
- country
Continent
- country
- country
?
-
I have found in documentation column > filter example:
JSON data i.e. [ { labelIndx: label1, valueIndx: value1}, { labelIndx: label2, valueIndx: value2},..]
labelIndx, valueIndx have to be provided in this case. groupIndx can also be provided when grouping is required in select list.
but my json don't works:
[
{
groupIndx: "Copywriting",
labelIndx: "yyy",
valueIndx: 14
},
{
groupIndx: "Copywriting",
labelIndx: "yyy",
valueIndx: 15
},
{
groupIndx: "Copywriting",
labelIndx: "Visual tekst",
valueIndx: 24
},
{
groupIndx: "Stylists Team",
labelIndx: "xxx",
valueIndx: 25
},
{
groupIndx: "Stylists Team",
labelIndx: "xxx",
valueIndx: 27
},
{
groupIndx: "Stylists Team",
labelIndx: "xxx",
valueIndx: 28
}
]
-
valueIndx, labelIndx and groupIndx are direct properties of filter
Please refer to the Shipping Region column of online demo. http://paramquery.com/pro/demos/filter_header
{ title: "Shipping Region", width: 130, dataIndx: "ShipRegion",
filter: { type: 'select',
//attr: "multiple", //for multiple
//style:"height:120px;",//for multiple
condition: 'equal',
//condition: 'range', //for multiple
valueIndx: "ShipRegion",
labelIndx: "ShipRegion",
groupIndx: "ShipCountry",
prepend: { '': '--Select--' },
listeners: ['change']
}
},
The JSON data for it is:
[{"ShipCountry":"Argentina","ShipRegion":null},{"ShipCountry":"Austria","ShipRegion":null},{"ShipCountry":"Belgium","ShipRegion":null},{"ShipCountry":"Brazil","ShipRegion":"RJ"},{"ShipCountry":"Brazil","ShipRegion":"SP"},{"ShipCountry":"Canada","ShipRegion":"BC"},{"ShipCountry":"Canada","ShipRegion":"Québec"},{"ShipCountry":"Denmark","ShipRegion":null},{"ShipCountry":"Finland","ShipRegion":null},{"ShipCountry":"France","ShipRegion":null},{"ShipCountry":"Germany","ShipRegion":null},{"ShipCountry":"Ireland","ShipRegion":"Co. Cork"},{"ShipCountry":"Italy","ShipRegion":null},{"ShipCountry":"Mexico","ShipRegion":null},{"ShipCountry":"Norway","ShipRegion":null},{"ShipCountry":"Poland","ShipRegion":null},{"ShipCountry":"Portugal","ShipRegion":null},{"ShipCountry":"Spain","ShipRegion":null},{"ShipCountry":"Sweden","ShipRegion":null},{"ShipCountry":"Switzerland","ShipRegion":null},{"ShipCountry":"UK","ShipRegion":null},{"ShipCountry":"UK","ShipRegion":"Essex"},{"ShipCountry":"UK","ShipRegion":"Isle of Wight"},{"ShipCountry":"USA","ShipRegion":"AK"},{"ShipCountry":"USA","ShipRegion":"CA"},{"ShipCountry":"USA","ShipRegion":"ID"},{"ShipCountry":"USA","ShipRegion":"MT"},{"ShipCountry":"USA","ShipRegion":"NM"},{"ShipCountry":"USA","ShipRegion":"OR"},{"ShipCountry":"USA","ShipRegion":"WA"},{"ShipCountry":"USA","ShipRegion":"WY"},{"ShipCountry":"Venezuela","ShipRegion":"DF"},{"ShipCountry":"Venezuela","ShipRegion":"Lara"},{"ShipCountry":"Venezuela","ShipRegion":"Nueva Esparta"},{"ShipCountry":"Venezuela","ShipRegion":"Táchira"}]
-
Thanks, you helped me!