IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this community and its apps will no longer be available. More details available on our FAQ.
Topic
  • 6 replies
  • Latest Post - ‏2019-09-23T14:07:16Z by takahak
takahak
takahak
69 Posts

Pinned topic Table sort

‏2019-09-18T03:31:25Z |

Hello,

I'd like to sort a table with "col2" column when the table is loaded.

I defined "me.sort("col2", false, false);" for the table's load event handler. The result is like sort_init.png. Both col1 and col2 are strings.

I don't know by how the col2 is ordered. My usage of sort() method isn't correct? I expected sort_desc.png with the above definition.

 

Thank you, Koichi

  • Atanu
    Atanu
    209 Posts
    ACCEPTED ANSWER

    Re: Table sort

    ‏2019-09-23T11:56:35Z  
    • takahak
    • ‏2019-09-21T06:04:53Z

    Hello Atanu,

    Even the column date type is Date, they aren't sorted.

    See attached table_sort.png.

     

    Thank you, Koichi

    Hi Koichi,

     

    Use column number instead of column name, that would solve your problem - 

    me.sort(1, false, false);
    

     

     - Atanu Roy

  • Atanu
    Atanu
    209 Posts

    Re: Table sort

    ‏2019-09-19T04:03:08Z  

    The problem is with the data type of column 2, it should be of Date type in order to be sorted by date.

     

    - Atanu Roy

  • takahak
    takahak
    69 Posts

    Re: Table sort

    ‏2019-09-19T04:41:16Z  
    • Atanu
    • ‏2019-09-19T04:03:08Z

    The problem is with the data type of column 2, it should be of Date type in order to be sorted by date.

     

    - Atanu Roy

    Hello Atanu,

    Thank you for your response.

    Column 2 is a string data type. Cannot the string type be sorted? But pushing up/down arrow at column 2 can sort string data.

     

    Thank you, Koichi

  • Atanu
    Atanu
    209 Posts

    Re: Table sort

    ‏2019-09-19T04:45:01Z  
    • takahak
    • ‏2019-09-19T04:41:16Z

    Hello Atanu,

    Thank you for your response.

    Column 2 is a string data type. Cannot the string type be sorted? But pushing up/down arrow at column 2 can sort string data.

     

    Thank you, Koichi

    Hi Koichi,

     

    It can be sorted but that would be treated as a string and would be sorted on that way. 

    The order might not be as expected as the order of sorted dates.

    Can you try to change the type to Date and sort ?

     

    - Atanu Roy

  • takahak
    takahak
    69 Posts

    Re: Table sort

    ‏2019-09-21T06:04:53Z  
    • Atanu
    • ‏2019-09-19T04:45:01Z

    Hi Koichi,

     

    It can be sorted but that would be treated as a string and would be sorted on that way. 

    The order might not be as expected as the order of sorted dates.

    Can you try to change the type to Date and sort ?

     

    - Atanu Roy

    Hello Atanu,

    Even the column date type is Date, they aren't sorted.

    See attached table_sort.png.

     

    Thank you, Koichi

    Attachments

  • Atanu
    Atanu
    209 Posts

    Re: Table sort

    ‏2019-09-23T11:56:35Z  
    • takahak
    • ‏2019-09-21T06:04:53Z

    Hello Atanu,

    Even the column date type is Date, they aren't sorted.

    See attached table_sort.png.

     

    Thank you, Koichi

    Hi Koichi,

     

    Use column number instead of column name, that would solve your problem - 

    me.sort(1, false, false);
    

     

     - Atanu Roy

  • takahak
    takahak
    69 Posts

    Re: Table sort

    ‏2019-09-23T14:07:16Z  
    • Atanu
    • ‏2019-09-23T11:56:35Z

    Hi Koichi,

     

    Use column number instead of column name, that would solve your problem - 

    <pre dir="ltr">me.sort(1, false, false); </pre>

     

     - Atanu Roy

    Thank you, Atanu.

    Column number works fine.

     

    Koichi