• Martin Lorenz
    April 14, 2017 at 4:56 am #4127

    Hello,
    I have problem with sorting string in table. When my string values, they have at first only small or big letter, everything work correctly but when I have array which has string values with first letters, different size, problems star. For example, I have string array:

    abc
    bcd
    Abc
    Def
    cde
    Efg

    Properly sorted list it should look like this:

    abc
    Abc
    bcd
    cde
    Def
    Efg

    but when I use sort in table, I get a sorted list in this way

    abc
    bcd
    cde
    Abc
    Def
    Efg

    In the beginning, I have values that start small letter, next all values that start big letter. I think that sorting works badly. Please help.

    SPARK Support
    April 14, 2017 at 3:59 pm #4130

    Hi Martin,

    The Table sort method is simply using the ASCII value of the character to determine the sort order:

    https://www.w3schools.com/charsets/ref_html_ascii.asp

    If you want to change the default sort order, set the Column to Render As a Custom type.  Then create a custom function to define the sort value of each value as you like.  The On  Custom Cell event provides access to the cell variable, which provides the property sortValue (cell.sortValue).

    Regards,

    Stephen P.

    Martin Lorenz
    April 15, 2017 at 1:48 am #4131

    Hello,
    Thank you very much for you response :). I understand, that I have to create my own sort method. How I can call this method? Where? In which table event? Do you have any examples?

    Saroj Panda
    April 24, 2017 at 6:07 am #4187

    Hi Martin,

    It would be nice if you do some homework before. Below link explains the usecaes of cell.sortValue. This can be helpful to you 🙂

    http://support.salientprocess.com/forums/topic/table-sorting-and-nested-objects-issue/#post-3753

    Meanwhile here is the steps which you can follow to get this custom sorting work

    1. Write below script in CustomHTML
      <script>
      function renderCell(table, cell) {
      if (cell.colIndex == 0) {// assuming it’s 1st column
      cell.setSortValue(cell.value.toUpperCase());// you can try with lowerCase too
      }
      return “S”;
      }
      </script>
    2. Set the Column render as option to Custom for required column.
    3. In Table On Custom Cell event write @renderCell

    Please note, you need to compromize with the order of Upercase and lowercase texts.

    Regards,
    Saroj

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Start typing and press Enter to search