Search code examples
pega

How to sort a text containing numbers by numbers' values?


I have got a repeat layout with the several columns. One of them prints data as "123 days", so it is Text. When I try to order rows by the column, I get something like: "121 days", "122 days", "123 days", "13 days", "124 days".

A property of the column is contained in the Data Base as Integer, but there is an activity, which converts it into Text adding "days". I suppose that the solution of the issue is utilizing Number despite of Text, but displaying "days" is a business requirement and I am not able to just throw it out.

Are there any workarounds to display "days" and to order the column as Number? Thank you.


Solution

  • Yes, there is a workaround. You need to create your own Control rule to display Number + "days".

    Don't append days through the activity. Keep numbers as it is. You must be using Text Input control to display the property.

    Create you own control. Uncheck the Auto-Generated? check box from HTML tab.

    In the code part write this.

    <%= tools.getActiveValue() %> days
    

    Thats it.