Menu
Download Free Trial

How to define order/sort for JSON data

How can I define a specific order to display rows in? I a custom  order I want the rows to display in, which I was previously doing using the following method in the XML configuration.
 

<sort>
<member>Display first</member>
<member>Second row</member>
<member>000 Display third</member>
</sort>

We’ve since moved to the more efficient JSON configuration and can’t quite find how to replicate this feature …
 
Thanks
Ash
 

6 answers

Public
Iryna Kulchytska Flexmonster August 3, 2016

Hi Ash,
 
Here is a sample of how to set custom sorting for hierarchy members in JSON report:
https://jsfiddle.net/irynakulchytska/mgu92Lvn/
 
In report object when you define rows/columns, please specify customSorting array for the hierarchy, as follows:

var report = {
  data: jsondata,
  viewType: "grid",
  rows: [{uniqueName: "Color", customSorting: ["green", "yellow", "red", "blue"]}],
  columns: [{uniqueName: "[Measures]"}],
  measures: [{uniqueName: "Price"}]
};

Please let me know if it works for you.
 
Kind regards,
Iryna

Public
Ashley Murphy August 10, 2016

That seems to be exactly what I need. I’m having one issue with it, it only seems to work if what you’re attempting to sort on is all lowercase characters.
 
Example of what I’m trying to do here: https://jsfiddle.net/ybLozo7e/1/
Same Example of it working with only lowercase characters: https://jsfiddle.net/rL5Lxky0/1/ 
 
Any help appreciated!
Ash

Public
Dmytro Zvazhii Flexmonster August 10, 2016

Hi Ash,
Thank you for reporting this issue. We have reproduced it on our side. The fix will be available in the next minor release version 2.219 ETA Aug15.
Best regards,
Dmytro.

Public
Ashley Murphy August 11, 2016

Great!

We have a release to do late next week using this feature, so please let me know if there will be any delays!

Ash

Public
Iryna Kulchytska Flexmonster August 11, 2016

Hi Ash,
 
The fix will definitely be included into the next minor release 2.219 that will be available on Aug 15.
 
Kind regards,
Iryna

Public
Tanya Gryshko Flexmonster December 7, 2016

Hello Ash and all Flexmonster users,
After the release of version 2.3, we would like to inform you that customSorting property was renamed to sortOrder. The structure of report was changed. JSON report objects of the previous version and XML reports are fully supported in terms of backward compatibility. It means you can open or set reports from the previous major version.
Please note, that all reports will be saved in new JSON structure. Find more details about new JSON structure in the documentation: Report Object.
Check the updated sample:
https://jsfiddle.net/flexmonster/a19kq36c/
Regards,
Tanya

Please login or Register to Submit Answer