• Resolved default587

    (@default587)


    Hi,

    I have some difficult using “order” function of tablepress plugin.

    I have a table with rows like this

    String | first_number | second_number | third_Number | = First * second * third

    I would like ti order the table basing on the last column, I tried putting “order”: [[ 4, ‘desc’ ]] in custom command section but, After saving, when i click on “preview” button the sort is not correct (it seems that it don’t take the order command).

    Can someone help me? (Note: the columns *_number are hided)

    Thank you!

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    The Preview will not take into account these arguments! You will have to check this, with DataTables and the sorting enabled, on an actual page.
    Then, as you are hiding the three columns in the middle, the correct “Custom Command” should be

    "order": [ [ 1, "desc" ] ]
    

    Can you please try that?

    Regards,
    Tobias

    Thread Starter default587

    (@default587)

    Hi Tobias,

    firsto of all, thank you for the fast answer.

    I’ve tried to put the shortcode of my table in an article and publish it into my website. Unfortunately, it still not works 🙁

    I can’t put some screen in this forum, I try to explain my steps:
    1. I created a new table as wxplained before, with 12 rows and 5 column. The first column is a string (visible), the next three columns are numbers (hidden) and the last one is a formula (= (B2 * 0.5) + (C2 * 0.3) + (D2 * 0.2)).
    2. in edit page, at the end of it, I copied your string in the text area “custom commands” and select the checkbox “Use the following properties from the Javascript DataTables library with this table:” (it is translated from Italian, I don’t know if it is the same in english)
    3. I created a new article and used the chortcode: “[table id = 1 /]”

    Thank you and regards,

    Simone

    P.s. Sorry for the error in the topic’s title … i can’t change it 🙁

    • This reply was modified 5 years ago by default587.
    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    this sounds all correct. Can you please post a link to the page with the table where this problem happens, so that I can take a direct look? Thanks!

    Regards,
    Tobias

    Thread Starter default587

    (@default587)

    Hi Tobias,

    here the link of my website:

    https://padellandoleague.altervista.org/ranking/

    thank you and regards,

    Simone

    • This reply was modified 5 years ago by default587.
    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks!

    Can you please also enable the “Sorting” checkbox in the DataTables section?

    Regards,
    Tobias

    Thread Starter default587

    (@default587)

    Yes sorry, i’ve enabled it (I’m seeing that the sorting is not working also from Front end side, strange, maybe is there some error in my formula? The numbers are not recognized by the plugin?)

    • This reply was modified 5 years ago by default587.
    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    are you sure that it’s enabled? It doesn’t look like it right now (and that’s why the table is not sortable on the frontend).

    Regards,
    Tobias

    Thread Starter default587

    (@default587)

    Can you try again now? Sorry

    Thread Starter default587

    (@default587)

    seeing the table, it seems that it takes the lenght of the number (like a string) and not the numeric value.

    For this reason the fisrt value (in descending order) is 196.5 (5 characters), followed by 94.5 (4 characters) and after the alphbetical order of the other numbers with 3 characters

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    frontend sorting is still turned off for me. It must be enabled for this command to work.

    Regards,
    Tobias

    Thread Starter default587

    (@default587)

    I don’t know why… i’ve checked the option “Enable the visitor to sort the table.” and if i visit my site at the beginning i see the sorting option…now it is not visible in the FE anymore (but in admin console the check is on).

    I performed now another saving from the admin console…now the sorting option appear again…

    • This reply was modified 5 years ago by default587.
    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    yes, now it works for me. Thanks! 🙂

    Ok, the sorting now is incorrect, because JavaScript library is configured to use the , as the decimal separator, and the . as the thousands separator (the defaults in the Italian language, that is configured for the site).
    Depending on what you want to use, you have two options:
    You could change the formulas to use a comma ,, by changing your formulas to

    =NUMBER_FORMAT_EU( (B2 * 0.5) + (C2 * 0.3) + (D2 * 0.2), 1 )
    

    Or, you could define English as the language for the table (and continue to use the .), by changing the Shortcode on the page to

    [table id=1 datatables_locale=en_US /]
    

    Regards,
    Tobias

    Thread Starter default587

    (@default587)

    I’ve tried changing the locale of my table, now the sort is better, but still not correct if i diseble it on the FE and using only the string “order”: [ [ 1, “desc” ] ] 🙁

    I’ve this situation (if the sorting function is disabled on the FE):

    Tommaso M.	189	
    Davide	        189	
    Marco G.	94.5	
    Tommaso D.	94.5	
    Simone G.	196.5	
    Costantino	196.5

    and also:

    Gianmarco	417	
    Gabriele	417	
    Antonio	        498	
    Simone C.	498

    189 and 94.5 appear before 196.5 and, in the second case, 417 is before 498 🙁

    If I enable the sort on the FE it works, but if i disable it (I would like to have a fixed table) the order doesn’t work

    • This reply was modified 5 years ago by default587.
    • This reply was modified 5 years ago by default587.
    • This reply was modified 5 years ago by default587.
    • This reply was modified 5 years ago by default587.
    • This reply was modified 5 years ago by default587.
    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    unfortunately, the command can only work if the frontend sorting is enabled.

    However, you could instead maybe simply use this TablePress Extension: https://tablepress.org/extensions/table-row-order/
    The Shortcode would then have to be

    [table id=1 row_order=sort row_order_sort_column=2 row_order_sort_direction=DESC /]
    

    Regards,
    Tobias

    Thread Starter default587

    (@default587)

    Ok thank you very much! For now I will mantain enabled the sorting function for the users.

    One last thing: is it possible to add a column with the row number? (I would like to display a ranking, so for the max number into column one, display another one with value “1”, for the second “2” and so on).

    Thank you again and regards,

    Simone

Viewing 15 replies - 1 through 15 (of 18 total)

The topic ‘Sort troumble’ is closed to new replies.