Search Support
-
Martin LorenzApril 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 SupportApril 14, 2017 at 3:59 pm #4130Hi 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 LorenzApril 15, 2017 at 1:48 am #4131Hello,
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 PandaApril 24, 2017 at 6:07 am #4187Hi 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
- 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> - Set the Column render as option to Custom for required column.
- In Table On Custom Cell event write @renderCell
Please note, you need to compromize with the order of Upercase and lowercase texts.
Regards,
Saroj - Write below script in CustomHTML
-
|
You must be logged in to reply to this topic.