• Resolved lipskas

    (@lipskas)


    Using the latest version of plugin. Previously I used JSON format to import tables, but I need extra DataTables functionality (support for HTML5 data-order attribute for specified cells), so I switched to pure HTML.

    Problem: when table is imported, all HTML5 attributes are removed. Let’s say HTML file looks like this:

    <table>
        <tr><td data-order='1'>Monday</td><tr>
        <tr><td data-order='2'>Tuesday</td><tr>
        <tr><td data-order='3'>Wednesday</td><tr>
        <tr><td data-order='4'>Thursday</td><tr>
        <tr><td data-order='5'>Friday</td><tr>
        <tr><td data-order='6'>Saturday</td><tr>
        <tr><td data-order='7'>Sunday</td><tr>
    </table>

    After import it becomes:

    <table>
        <tr><td>Monday</td><tr>
        <tr><td>Tuesday</td><tr>
        <tr><td>Wednesday</td><tr>
        <tr><td>Thursday</td><tr>
        <tr><td>Friday</td><tr>
        <tr><td>Saturday</td><tr>
        <tr><td>Sunday</td><tr>
    </table>

    Which causes problems because sorting for such column works not as user expects. How can I preserve HTML5 attributes during HTML import (or how can I add them to JSON file)?

    P.S. I also noticed that plugin uses very old version of DataTables. Could you update it, please?

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

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Unfortunately, I’ll have to disappoint you here. The problem is not so much the import of these attributes, but that TablePress does not have a way to save them in its table format – it can only save the cell content.

    As an alternative, I recommend to add these attributes dynamically, e.g. via the tablepress_cell_tag_attributes filter hook (see https://github.com/TobiasBg/TablePress/blob/master/classes/class-render.php#L716 ). Or, you could try adding this information for DataTables via a “Custom Command” on the table’s “Edit” screen.

    Regarding the DataTables version: TablePress currently uses 1.10.25, which is the latest version in the 1.10 branch (and not “very old” on my opinion ?? ). Switching to the current 1.11.3 is planned for the next major update of TablePress, as I also have to take into account potential issues with backwards-compatibility.

    Regards,
    Tobias

    Thread Starter lipskas

    (@lipskas)

    Thank you for the response. I checked the tablepress_cell_tag_attributes, but I’m not sure if it suits my needs. If I understand right, I need to utilize this in functions.php? Will it work if I know nothing about table? I mean every time the table is imported, it contains a different number of rows and data is slightly different. Also, I need to add data- attributes to more columns (not just weekdays), doesn’t it mean a lot of programming is involved here?

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    yes, depending on the structure of your tables, this could mean quite a bit of custom programming.

    Maybe, developing a custom sorting algorithm with type detection for DataTables (see https://datatables.net/plug-ins/sorting/ ) could be an option that. You could maybe use https://tablepress.org/extensions/datatables-sorting-plugins/ as a foundation for that.

    Regards,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Importing Table Removes HTML5 data- Attributes’ is closed to new replies.