ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: mshapiro on August 12, 2015, 05:13:49 am
-
I have string columns in some grids where select filters are populated from the column values. As in:
{
title: "Gr Name", dataType: "string", dataIndx: "GrName", width: 200,
filter: {
type: 'select', condition: 'equal', valueIndx: "GrName", labelIndx: "GrName",
prepend: { '': '--Select--' }, listeners: ['change']
}
}
then after json load:
var column = $gridPeerGroups.pqGrid("getColumn", { dataIndx: "GrName" });
var filter = column.filter; filter.cache = null;
filter.options = $gridPeerGroups.pqGrid("getData", { dataIndx: ["GrName"] });
This works fine unless a column value has sequences of 2 or more spaces. When that happens, then selecting that entry in the filter drop down will not result in a match. My workaround is to replace multiple spaces in the filter options with hard spaces as in
for (var i = 0; i < filter.options.length; i++) {
filter.options.GrName = replaceAll(' ', ' ', filter.options.GrName);
}
function replaceAll(find, replace, str) {
return str.replace(new RegExp(find, 'g'), replace);
}
Then there is a match when that option is selected in the filter and the correct row(s) are displayed. Is this the expected behavior? Is there a better way to do this? Thanks
-
That is expected behavior.
For condition = "begin"
"Yvonne" would match "Yvonne Moncada"
"Yvonne " would also match "Yvonne Moncada"
but "Yvonne M" won't match "Yvonne Moncada" because there is one space in the former and 3 spaces in the latter.
-
To be clear, the expected behavior is that if the select condition is 'equal' and one of the column values is "This has 3 spaces" then an entry of
"This has 3 spaces"
in the filter options will not result in a match when it is selected, but an entry of
"This has 3 spaces"
will result in a match? Thanks.
-
Ok got it, the select list is removing any extra spaces beyond one in the options, which should not be the case, it's being investigated further.
As an alternative workaround, please use the condition as below callback instead of 'equal'.
condition: function(a, b){
if( a.replace( /\s/g, '' ) == b.replace( /\s/g, '' ) ){
return true;
}
},