Support » Plugin: TablePress » Custom CSS Class for rows, columns

  • Resolved nimmolo

    (@nimmolo)


    Hi Tobias,
    Thank you for the plugin. I don’t know how you handle so many support requests!

    Feature request: it would be nice to set row-level/column-level custom css classes in the admin *and have the classes be a property of the row/column*, travelling with the row /column, in the case of inserts.

    Targeting a row/column CSS class by number is unfortunately not practical for tables which may be updated periodically by a client.

    The reason I’d like this is to highlight rows within the document.

    • This topic was modified 1 year, 5 months ago by  nimmolo.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    I see what you mean. Adding extra input fields for such CSS classes is not something that I’m planning at the moment. It would just confuse the “average” user, and those are the majority.

    However, there is a solution idea for what you are trying to achieve: You might want to play with the TablePress Row Highlight Extension. Please see these threads for inspiration:
    https://wordpress.org/support/topic/highlight-rows-using-table-manipulation/
    https://wordpress.org/support/topic/highlighting-a-selection-of-rows/

    Regards,
    Tobias

    Thanks Tobias. Interesting.

    Ah – with that extension, but not using the shortcode method, can I just add class “row-highlight-foobar” to the table itself? And a script will work the magic?

    My site adds the tables via templates and the ACF TablePress plugin, so no shortcodes

    • This reply was modified 1 year, 5 months ago by  nimmolo.
    • This reply was modified 1 year, 5 months ago by  nimmolo. Reason: aha!
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    I don’t see why you can not use the Shortcode parameter.
    ACF TablePress only returns the table ID.
    And with “adds the tables via templates”, do you mean that you are using the TablePress Template Tags to insert the table? Do you have an example?
    You can also use the Shortcode parameters in that.

    Regards,
    Tobias

    Hi Tobias –

    ACF TablePress has an option to return the table HTML, or the ID. I return the full HTML and echo that in the template, echo get_field( $table );

    I could perhaps return the ID and then use echo do_shortcode in the template, with the row-highlight parameter, but the client needs to choose which rows to highlight in their table – these will be changing along with the table revisions.

    In this site the tables will be often changing, but they appear in the template within js-activated-tabs, quite separate from the_content.

    Use on page

    For this page I’ve basically just broken up the tables at every row that gets highlighted, so that it will get the automatic <thead> styling.

    I suppose also I could make some WYSIWYG ACF fields where the client could type out the shortcode, but … it’s not a shortcode kind of client 🙂

    • This reply was modified 1 year, 5 months ago by  nimmolo.
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    I don’t see a problem with making that change to echo do_shortcode (or actuall rather tablepress_print_table( ... );. It just gets the extra parameter to turn on the highlight of rows that contain the special keyword.
    The client would never have to modify or edit that Shortcode/Template tag parameter.
    All they would have to do is add the special keyword into the desired rows when editing the table.
    They basically don’t even have to know about the Extension, just that adding special keywords in a certain table column (which can be hidden with CSS) will result in that row getting highlighted.

    Regards,
    Tobias

    Tobias thanks,

    why not just write up a quick page on your Tablepress site documenting the ways to use this feature? it looks like it’s been around 3 years now.

    The extra column is definitely workable, but… highlighting specific rows is pretty basic for layout control of tables. it doesn’t seem the documentation for this should be so obscure.

    Anyway – my question is how to pass the row-highlight arguments to the template tag tablepress_print_table function. I’ve read through the plugin code, but it’s still not clear. Does it go in an args array?

    • This reply was modified 1 year, 5 months ago by  nimmolo.
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    yeah, I should probably add this to the documentation. I guess I just didn’t really have time for it and didn’t feel in the mood…

    Yes, you would just add this as a parameter to the Template Tag function, like

    print_tablepress_table( array(
      'id' => '123',
      'row_highlight' => '...',
    ) );

    Regards,
    Tobias

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom CSS Class for rows, columns’ is closed to new replies.