The line gs += index +” “+grp.groupOrder[gi]+”, “; will result in ‘sidx’ like this id asc, (always comma at end). If inserted into SQL command this results in an error. I changed this line as follows:
Now you get correct ‘sidx’ like this id asc or id asc, name asc for multiple grouping. I also added prm.sord=’ ‘; after prm[pN.sort] = gs + prm[pN.sort]; so that sort order is only in ‘sidx’ and not in both ‘sidx’ and ‘sord’.
There is also an issue with grouping if you first sort a field (asc or desc) and then try to group. The ‘sidx’ is like this id asc, id (it picks up the field name that was sorted before grouping).
At the moment I’m not sure where this field name is coming from.