We are upgrading both jQuery and jqGrid in a project and found a possible bug in jqGrid. The versions we are working with:
- jQuery 1.4.1 upgraded to 1.7.1
- jqGrid 3.8.2 upgraded to 4.2.0
We are using the colmodel's index parameter both for sorting and searching/filtering. The problem we have found appears when the index string contains a dot. E.g. "Customer.Name".
$('#grid').jqGrid({
url: 'some/controller/action',
datatype: 'json',
colNames: ['Customer Name'],
colModel: [{ name: 'CustomerName', index: 'Customer.Name' }]
});
$('#grid').jqGrid('filterGrid', '#filter',
{
filterModel: [{ label: 'Customer Name', name: 'CustomerName', stype: 'text' }]
});
When the search is used the browser throws an exception as follows:
Syntax error, unrecognized expression: [name=Customer.Name]
http://localhost:8000/Scripts/jquery-1.7.1.js Line 4179
The exception is originating from row 465 in grid.addons.js which looks like this:
447: nm = this.index;
465: v = $("input[name="+nm+"]",self).val();
The code is inside an each operator and gets the value from the colModel/filterModel, so this
is each element in that array.
After some research we found that in jQuery 1.5 the attribute selector requires quotes around the value, which the grid doesn't seem to use and thus failing when searching for the element.
Question is: Is there any workaround for this or should we post a bug to jqGrid and hope they fix it soon?
We have tried escaping the dot and surrounding the string with quotes, but nothing helps.