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