18
Views
2
Comments
Solved
How can I proper sort a list on an reactive app?
Question

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.



Rank: #95
Solution

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):

  • One ListSort action for field Name (Text);
  • Another ListSort action for fields AccountNumber (Integer) and Balance (Decimal);
  • Another ListSort action for field CreatedOn (Date).


Hope that this helps you!


Kind regards,

Rui Barradas

Champion
Rank: #99

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

Rank: #95
Solution

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):

  • One ListSort action for field Name (Text);
  • Another ListSort action for fields AccountNumber (Integer) and Balance (Decimal);
  • Another ListSort action for field CreatedOn (Date).


Hope that this helps you!


Kind regards,

Rui Barradas