• Resolved prabswal

    (@prabswal)


    I’m trying to change text background based on profit or loss in a table.

    Need to display large number of data table, one of the column is profit or loss. Please tell how can i change background color red if its loss(-100 in Jan 2010) and green if plus or profit (+100 in Feb) based on value on the cell.

    Table
    ——-
    SEA Sept 17th/2010 $0.32 Mar 4th/2011 $1.02 [+218% in 6 months]GREEN
    EQN Nov 5th/2010 $6.34 Feb 25th/2011 $6.22 [-2% in 3 months]RED

    https://www.ads-software.com/plugins/tablepress/

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

    (@tobiasbg)

    Hi,

    thanks for your question.

    Unfortunately, I don’t have a working solution to this, but it should not be too hard to do this with some custom coding. You’ll want to hook into the “tablepress_cell_css_class” filter hook (see class-render.php), and then check the cell content. Depending on whether it is positive or negative, you can then return an additional CSS class to the cell, which you can use to style the background color of the cell.

    Regards,
    Tobias

    And if you use a hidden column, where the calculated absolute value (or manually stamped “+” or “-“), and then use extension “tablepress-row-highlighting”?
    https://www.ads-software.com/support/topic/highlight-a-row-based-on-value?replies=10
    So do not you get?

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    yes, that’s also a very nice idea! ??
    With that, you could add a class to each row, that signifies whether the value in the row is positive or negative. Then you will just need to use some “Custom CSS” to only apply the styling to the cell with the value.
    Thanks for the suggestion!

    Regards,
    Tobias

    Thread Starter prabswal

    (@prabswal)

    Thanks Arkona and Tobias for quick response, somehow tablepress-row-highlighting is not working for me.

    I’ve double these
    – Did you really activate the new plugin? YES
    – Did you modify the Shortcode? YES
    – Does the table contain the exact word in a cell (by default, the Extension does exact cell matching)? YES for the sake of getting it right i’ve even used yes instate of + or –
    – Did you add the “Custom CSS”? YES
    and this is the site
    site
    Wordpress Ver 3.6.1

    Would appreciate your efforts…

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    just for clarity, could you please post the Shortcode that you used?

    Then, it seems that you have entered the “yes” followed by a space, i.e. as “yes “. That space could be breaking the exact cell matching, so please remove that.

    Finally, the correct “Custom CSS” code would be

    .tablepress-id-2013 .row-highlight-yes .column-6 {
    	color: #ff0000 !important;
    }

    Regards,
    Tobias

    Thread Starter prabswal

    (@prabswal)

    Hi Tobias,

    This is the shortcode used.

    [table id=2013 row_highlight=’yes’ /]

    I’ve made the correction on custom CSS.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    can you please try with

    [table id=2013 row_highlight="yes" /]

    I’m not sure right now, if WordPress recognizes single quotes ' in the Shortcodes.

    Also, there’s still that space after “yes”, as mentioned in my last post. Please remove that.

    Regards,
    Tobias

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘format table cells based on value’ is closed to new replies.