Hi Team,
We have a requirement at our side to separate out Measure(number) fields and the dimension(string) field. I understand that the fields right now are in alphabetical order. But is there a way to show string fields first and then number fields. Is there any workaround to change the sorting of field elements?
Regards.
Hello, Sumukh,
Thank you for your question.
We have prepared an example demonstrating one of the possible approaches to achieve the desired functionality. The list of hierarchies will be sorted in the following way: hierarchies which are not considered as measures (string data type) will be placed first in alphabetical order. After them, all measures (number data type) will be displayed. They will be sorted in alphabetical order as well.
Our team would like to provide some additional explanation about the following code snippet responsible for sorting hierarchies in the desired way:
pivot.on("fieldslistopen", () => {
let temporary = [];
setTimeout(() => {
let fieldList = document.querySelector("#fm-lst-hierarchies");
for (let i = 0; i < fieldList.childNodes.length; i++)
for (let singleClass of fieldList.childNodes[i].classList)
if (singleClass == "fm-measure") {
temporary.push(fieldList.childNodes[i]);
fieldList.removeChild(fieldList.childNodes[i]);
i--;
}
for (let field of temporary)
fieldList.appendChild(field);
}, 0);
});
It is executed after the fieldlistopen
event is triggered.
The list of all hierarchies can be received through the following selector: "#fm-lst-hierarchies"
. Next, all child nodes of the list are checked and the ones containing the "fm-measure"
class are removed from the list. Such elements are saved in the temporary
array and appended back to the list after filtering is finished. They are appended to the end of the list keeping an alphabetical order.
Please note that setTimeour
should be set in order to make sure that the element is created after the Field List is opened.
Detailed information about the fieldlistopen
event can be found in our documentation.
We sure hope it works fine for your case.
Please contact us in case of additional questions.
Best regards,
Illia
That was quick and in detail. Highly appreciated.
Thank you.
Hello, Sumukh,
Hope you are doing well.
Our team is happy to announce that we have added a new API call sortFieldsList()
for sorting Field List items.
This feature is included in the 2.9.17 version of Flexmonster: https://www.flexmonster.com/release-notes/version-2917/. Here is our updating to the latest version guide for assistance: https://www.flexmonster.com/doc/updating-to-the-latest-version/.
You can find more information on using the new API call in our documentation: https://www.flexmonster.com/api/sortfieldslist/.
You are welcome to write to us in case further questions arise.
Kind regards,
Nadia
Hi Nadia,
We tried to make the sort order like this:
The measures are in a folder Called Measures (Medidas in portuguese) and grouped by the Measures Grpups (in the example Pedido). The measure is QtPedido (Quantity of Orders).
In the attached File there is a print of how we would like to see the values.
Could you please help up on how to make this sort at fildes list ?
kind regards,
Nelson
Hello,
Thank you for contacting us.
We suggest the approach where you place all the Measure Folders on the top of the list and sort alphabetically Measures and other fields separately.
Please check the following JSFiddle we prepared for you: https://jsfiddle.net/flexmonster/3ohzmL2x/
Kindly note that the sample uses data from our cube, but the same approach would work for your data.
Please let us know if it works for you. Feel free to contact us if other questions arise.
Best regards,
Nadia
Hello, Nelson!
Hope you are doing well.
Just checking in to ask if you had some time to try the suggested sorting approach. Could you please let us know if it works for your case?
Looking forward to hearing from you.
Regards,
Solomiia
Hello, Nelson!
Hope you are having a great week.
Our team is wondering if the suggested sorting approach was helpful for your case.
Looking forward to your response.
Regards,
Solomiia