Default sorting order ascending for all fields

Answered
Kapil Dhokai asked on July 18, 2023

Hey,
 
Can we set default sorting order as "ascending" for all the fields.
 
If I don't want to set sorting order of selected fields on event every time.
 

10 answers

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster July 19, 2023

Hello Kapil,

Thank you for reaching out to us.

Could you please provide us with more details on your use case:

  1. Which grid layout do you use? (compact/classic, or flat form)
  2. If you use the compact or classic form, what is the expected sorting result? (sorted members or sorted values)

It would greatly help us.

Looking forward to hearing from you.

Kind regards,
Nadia

Public
Kapil Dhokai July 19, 2023

# "Compact" form AND some time "Flat" form
# Sorted members(Rows/Columns), Not a value.

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster July 20, 2023

Hello Kapil,

Thank you for providing the details.

We recommend using the defaultHierarchySortName property of the Options Object. To set the default sorting order as "ascending" for all the fields, you can use the following code:

report: {
...,
   options: {
     defaultHierarchySortName: "asc"
   }
}

You are welcome to check the following JSFiddle for reference: https://jsfiddle.net/flexmonster/cdh2pwo8/ 

Please let us know if it works for you. Looking forward to hearing from you.

Kind regards,
Nadia

Public
Kapil Dhokai July 24, 2023

Its not working, any other option?

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster July 25, 2023

Hello,

Thank you for the response.

We could not reproduce the issue with the defaultHierarchySortName: "asc" on our side. Please edit the JSFiddle from our previous response to show the problem. It would greatly help us.

Looking forward to hearing from you.

Kind regards,
Nadia

Public
Kapil Dhokai July 26, 2023

Adding code in JsFiddle 
Some fields like: Market, Brand, Category, Ads, Month, Quarter   not getting sorted default in Row/column. Let me know any other configuration/code required.
 
 

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster July 27, 2023

Hello,

Thank you for providing us with the example.

It seems that in your report configuration, you have the measures sorted:

"sorting": {
      "row": {
        "type": "desc",
        "tuple": [],
        "measure": {
          "uniqueName": "AdBlockId",
          "aggregation": "distinctcount"
        }
      },
      "column": {
        "type": "desc",
        "tuple": [],
        "measure": {
          "uniqueName": "AdBlockId",
          "aggregation": "distinctcount"
        }
      }
},

Please note that it is only possible to sort data by members or measures. This means if you remove the measures sorting, the members will be sorted in ascending order: https://jsfiddle.net/flexmonster/kmz7u52t/2/ 

Please let us know if it works for you. Looking forward to hearing from you.

Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster August 16, 2023

Hello,

Hope you are doing well.

We were wondering if you had a chance to check the suggested solution. Could you please let us know if it works for you?

Looking forward to hearing your feedback.

Kind regards,
Nadia

Public
Kapil Dhokai August 16, 2023

Its working now, thanks for your help

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster August 16, 2023

Hello Kapil,

Thank you for the response.

We are glad to hear that it works for you!

As always, feel free to contact us in case other questions arise.

Kind regards,
Nadia

Please login or Register to Submit Answer