Hello guys, I am trying to do a sort of a table on a Responsive Application and I am getting a weird behavior. It work for some columns and for other doesn't. In the column name it works just fine, but, for instance, on the account number it appears random.
Can you help me?
I leave here some screenshots of the code.
Hello Bruno,
Hope you're doing well.
That behavior happens when you have different Data Types associated to one single ListSort action.
If you have different Data Types in a single ListSort, they will be assumed as a single Data Type and this may lead into some undesired behaviors.
For example, assuming that your Name field is a Text and your Balance field is a Decimal, if these fields are both in the same ListSort, your sorting will be executed considering both of them as Texts.
In this scenario, you need to separate your fields in several ListSort actions (depending on their Data Types).
Based on your Sort attribute, you can place an If / Switch widget to evaluate your fields and have a ListSort for each Data Type.
I believe that decimals, currencies and integers can be placed in the same ListSort, but you can test it out.
In your case, it should be something like (I'm assuming your Data Types):
Hope that this helps you!
Kind regards,
Rui Barradas
Hi,
The AccountNumber attribute type, is Text or Number? Because, if it's Text, you can have a sorting based in the characters codes and not in the number sequence.
Best regards,
Ricardo M Pereira
I know the question is marked as solved, but there's an easier way no to worry about the different data types of the sort attributes (if they are text, date, integer, identifiers..) and having lot's of List Sorts.
On the Sort By of the List Sort action, have all the if's returning ToObject() of their attributes.
And always remember to handle the descendant/ascendant behavior.
Hope this helps!
Hi All, I know this is very old, but i need this , can one can share oml of this .
I think @Fábio Godinho shared the screenshot, its enough to implement the sortIn case, there are a lot of fields to consider, I usually choose JavaScript to dynamically sort. Please check my attached JavaScript file, then just pass the list as text (JSON serialized) to the JavaScript node along with sort column name and order
Example usage:
const listItems = [
{ name: "Banana", price: 10 },
{ name: "Apple", price: 5 },
{ name: "Mango", price: 7 },
{ name: "Orange", price: 8 }
];
// Sort by name in ascending order
listItems.sort(dynamicSort('name', 'asc'));
console.log(listItems);
// Sort by price in descending order
listItems.sort(dynamicSort('price', 'desc'));
OML available?
Please refer to my attached oml for both local list sort
I'm trying to use this method but I'm getting a 'Generic Type' data type required instead of 'Object' error. It's incredible how difficult it is to solve this very basic issue.