• Resolved supergap

    (@supergap)


    Hi,
    i’m looking for a way to sort months (january, february, march…).
    of course (and it’s logic) if I sort them I have an alphabetical order. but unfortunately months don’t follow an alphabetical order.
    I would like to sort starting from january, februar…and so on.
    Any tip for that?

    thanks a lot

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    You would need a custom sorting algorithm that can recognize months.
    For some ideas, I suggest looking into the code of the TablePress Extension from https://tablepress.org/extensions/datatables-sorting-plugins/

    Another idea could be to work with a hidden column that has the corresponding number for the month in it, similar to the approach from https://www.ads-software.com/support/topic/date-order-6/

    Regards,
    Tobias

    Thread Starter supergap

    (@supergap)

    hi,
    it works fine thanks!

    I set: “columnDefs”: [ { “orderData”: [ 0 ], “targets”: [ 1 ] } ]
    hidden ‘ordering’ column is 0 and visibile data to sort are in column 1 (that is the second column on user side)

    BUT

    I’m not able to match this command to this other command that I like to use too:
    { “orderable”: false, “targets”: [ 2,3 ] }

    because I want to order column 1 (using the hidden column 0) but also avoid sorting in column 2 and 3.

    I used this (perhaps the syntax is wrong), but sorting disappears everywhere.

    “columnDefs”: [ { “orderData”: [ 0 ], “targets”: [ 1 ] } { “orderable”: false, “targets”: [ 1,2 ] }]

    Is it correct?
    thanks a lot

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    you need to add a comma between the two commands that are in { and }.

    Regards,
    Tobias

    Thread Starter supergap

    (@supergap)

    Fine!
    that’s perfect.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

    Thread Starter supergap

    (@supergap)

    Hi,

    Last but not least..

    using the same way is it possible also set text color / font weight for an entire column.
    If I’ve understand the way it works I do suppose NO.
    But I can not find a way in css, because table cells are dynamically generated..

    thanks again.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    all this would indeed work using CSS code. But I’m not sure why you are saying that this does not work?
    The CSS would be something like

    .tablepress-id-123 .column-3 {
      color: #ff0000;
      font-weight: bold;
    }

    with correct table ID and column numbers.

    Regards,
    Tobias

    Thread Starter supergap

    (@supergap)

    Hi Tobias,

    I was not certain. Because I was convinced that if you can create infinite columns it was not possible to assign a class.
    But I tried and it works fine.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    great! That’s good to hear ??

    Best wishes,
    Tobias

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘sorting months in a smart way’ is closed to new replies.