Something went wrong while trying to load the full version of this site. Try hard-refreshing this page to fix the error.

Tip/fix: Query grouping + Sorting

hpl123

Hi all,
Here is a tip to fix the bug with sorting not working in queries if you use grouping (i.e. if you use grouping and group data based on some attribute e.g. category, the sorting is not respected so no matter what you configure in the configtool etc. the sorting doesn´t work):
Add the following to the queries advanced (init) script and the field parameter is the sorting you want to use:

var ds = config.dataSource;
ds.serverSorting=false;
ds.sort = {field: "PriorityScoreTemp", dir: "desc"};

PointsWell

Should this work with shortcut fields?

I have a query that is grouped on a category name (sc_Status) but I want to sort on sc_StatusCode to override the alphabetic sort of sc_Status, but when I put the following into initialisation it still sorts by the Grouping

var ds = config.dataSource;
ds.serverSorting=false;
ds.sort = {field: "sc_StatusCode", dir: "asc"};

hpl123

Not sure but think it should work for shortcuts as well, try it with regular attributes and see if that works (and if that works but not the shortcut then I guess it´s something special with the shortcuts).


rprinzing

YES! That works.
However, what does the syntax need to look like if the sort is MORE than one field?
I need to sort by TimeAppointment, NameFirst.
Certainly hope future versions address this bug. Plus ONE.
Thanks!!!!


johntalbott

ds.sort = [{ field: "TimeAppointment", dir: "desc" }, { field: "NameFirst", dir: "asc" }]