Hello! Is any ability to retrieve field property(type = property) in the 'flexmonster.sortingMethod' comparator to may it possible to sort using some another value. Thank you in advance.
Hello,
Thank you for contacting us.
In order to use the member's property while sorting the hierarchy using the sortingMethod
, we suggest considering the following approach.
Get all members of the hierarchy using the getMembers
API call. Next, filter the received array so that only two currently compared members are left. The resulting objects will contain the specified property and can be used in order to sort the hierarchy itself.
Please see an example we have prepared.
Our team wants to provide some explanation about the following code snippet taken from the mentioned sample. It is responsible for sorting itself:
flexmonster.on("reportcomplete", () => {
flexmonster.off("reportcomplete");
let members = flexmonster.getMembers("Tenure");
pivot.sortingMethod("Tenure", function(a, b) {
a = members.filter(function(member) {
return member.caption == a;
})[0];
b = members.filter(function(member) {
return member.caption == b;
})[0];
return a.properties.Sorting > b.properties.Sorting ? 1 : -1;
});
})
Execution of the sortingMethod
is bound on the reportcomplete
event. Also, members are written in the members
variable as soon as the event is triggered.
After that, members are filtered and assigned to the a
and b
variables. Finally, 1 or -1 is returned based on the property of the chosen member.
Detailed information about used API calls and events can be found in our documentation:
Please let us know if it works for your case.
Do not hesitate to contact us in case additional questions occur.
Regards,
Illia
Hello, Sergii,
Our team is wondering whether the suggested approach was helpful for your case.
We are looking forward to hearing from you.
Regards,
Illia
Hello, Sergii,
We want to take an interest in whether our suggestion helped.
Our team is looking forward to hearing from you.
Regards,
Illia