• Resolved bbergman

    (@bbergman)


    Very interesting plugin, thank you! I’m investigating use of this to replace a couple of very flexible plugins we’ve used in the past that are no longer supported. One must-have need is the ability to change the sort column in the shortcode (not in the table definition).

    In reviewing your documentation, it looks like “datatables_sort” is a boolean, which should enable this, but I see no way to provide the actual column criteria. I can add it in the custom commands (such as “order”:[4, ‘asc’]), but then that applies to every use of that table, regardless of the shortcode calling it. In reading the datatables.js documentation, I can’t see how to pass the sort/order information via the shortcode.

    Ideally, it would be something like “datatables_sort=true order=”[4, ‘asc’]” in the shortcode, or something of that kind. Can you explain if this is something only provided in the premium version? If not, how do I actually pass in the column to sort on in the shortcode itself? Or if it’s not supported at all, that would also be helpful to know.

    Thanks!

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

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Supplying this information (e.g. that "order": [[ 4, "asc" ]] “Custom Command”) via the Shortcode is indeed not possible. The main reason is that these commands contain square brackets and quotation marks, which causes lots of trouble within the WordPress Shortcode parsing (where these square brackets and quotation marks have a special meaning, like the beginning and end of the Shortcode or as delimiters for parameter values). Therefore, these order commands for the DataTables JS library can indeed only be supplied on the “Edit” screen, so that they would apply to all instances of that table.

    Now, the premium versions might indeed offer a solution: They also contain the Row Order feature module, which does offer Shortcode parameter to pre-sort a table! (This sorting will the be done server-side, before the table is sent to the browser, and does not involve the DataTables JS library.)

    So, for showing differently sorted versions of the same table, maybe even in combination with different pre-filtering, this would be my recommended solution. If you have specific questions regarding these features, please also feel free to email me to the address from the bottom of https://tablepress.org/pricing/

    Best wishes,
    Tobias

    Thread Starter bbergman

    (@bbergman)

    Thanks, yes, I think the premium version is what is needed for this, then.

    It begs the question, though: what is the point of datatables_sort? If it can’t be used to sort, why does it exist? What does it do?

    Thanks!
    Bruce

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi Bruce,

    good to hear that the premium version will help!

    The datatables_sort parameter can be used to turn the frontend sorting feature on or off, using the Shortcode parameter (it’s essentially the equivalent to the “Sorting” checkbox on a table’s “Edit” screen). This is e.g. useful if a large version of a table is embedded on one page (which should be sortable by the site visitor), and if a smaller/pre-filtered version of the same table is embedded on a different page (where it should maybe not be sortable).

    bwtBest wishes,
    Tobias

    Thread Starter bbergman

    (@bbergman)

    Got it. Thanks again!

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

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

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Use of datatables_sort shortcode parameter?’ is closed to new replies.