Is there a way to tell the jqGrid to ignore the case while grouping? I don't want to change the data as some will be upper case, some lower case and others mixed case.
I'm using jqGrid 4.4.4
Is there a way to tell the jqGrid to ignore the case while grouping? I don't want to change the data as some will be upper case, some lower case and others mixed case.
I'm using jqGrid 4.4.4
The question is good, but ... the current implementation of grouping in jqGrid allow grouping only exact values. I remember close requirements when one wanted to group by month instead by exact date.
After some analyse of the source code of jqGrid I hope that I found very simple and very flexible way to do more flexible grouping. I suggest to modify the line
to
After this one can define
isInTheSameGroup
function inside ofgroupingView
:The demo display the following results:
I used in the demo modified version of
jquery.jqGrid.src.js
of jqGrid 4.4.5. The version ofjquery.jqGrid.src.js
of jqGrid 4.4.4 modified in the same way you can find here.I will post later my suggestion to trirand. I hope that the next version of jqGrid will contain the feature.
UPDATED: As promised, I posted the corresponding feature request to trirand.
UPDATED 2: I posted the pull request with a little more changes of grouping module of jqGrid. The demo demonstrates how new features can be used. It uses 2-level grouping and displays the following results:
UPDATED 3: The pull request which I sent to trirand is merged now to the main code of jqGrid. So the next version of jqGrid (after 4.4.5) will supports
isInTheSameGroup
andformatDisplayField
arrays of callbacks inside ofgroupingView
. If your case it would look likeThe callbacks
isInTheSameGroup[0]
andformatDisplayField[0]
will be used by grouping bygroupField[0]
. Because jqGrid support multilevel grouping theisInTheSameGrou
andformatDisplayField
properties are arrays of callback functions instead of just callback function.At the beginning of grouping jqGrid sort data by grouping column. One can use
sorttype
defined as function to customize the first step (see the answer). I don't though about the step during writing of your answer. Probably usage ofsorttype: function (cellvalue) {return String(cellvalue).toLowerCase();}
could already solve your problem.Then the function
isInTheSameGroup[level]
will be used consequently to compare the value of grouping column from of previous row with the corresponding value of the current row. The functionisInTheSameGroup[level]
will be called with the values. If your callback returnstrue
then the row will be grouped with the previous one.The callback
formatDisplayField[level]
allows to customize the information displayed in the grouping header. In the example above I convert the data to low case.