• Resolved jorg2

    (@jorg2)


    Hi there,

    is conditional formatting of values in a collumn based on rules possible?

    Example: Collumn “Sales”

    – If Sales < 10 then font color = red
    – If Sales >= 10 AND Sales < 100 then font color = yellow
    – If Sales >= 100 then font color = green

    If it’s not a built in function, is there a workaround?

    Best regards
    Jorg

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter jorg2

    (@jorg2)

    The best solution for me would be if the values (10, 100) could be defined dynamically based on sql-queries that select basic user inputs made before.

    Another solution for me could be to do conditional formatting based on the content of a hidden collumn “ColorCode”:

    – If ColorCode = 1 then font color Sales = red
    – If ColorCode = 2 then font color Sales = yellow
    – If ColorCode = 3 then font color Sales = green

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Jorg,

    This combination of conditions cannot be added using URL parameters. Sorry! But you can add a default where in your publications and projects. This is explained here:
    https://wpdataaccess.com/docs/documentation/data-publisher/adding-filters/
    https://wpdataaccess.com/docs/documentation/data-projects/adding-filters/

    I am currently extending the Query Builder with a visual component. When that part is ready, the next step is to support query based publications. I hope to have this available first quarter next year.

    Does this help?

    Thanks,
    Peter

    Thread Starter jorg2

    (@jorg2)

    Hi Peter,

    thank you for your instant reply.

    I understand that it’s possible to use complex statements / subqueries in where clauses. This makes a solution possible to
    – Filter by username with environment variable $$USERID$$ AND
    – Filter a subset of records for example that meet the condition (sales > 100)

    This makes it possible to devide the records of a large dataset into several output tables depending on conditions that are defined in the where clause (or Shortcode or URL Parameters). I bought the premium version and I’m currently testing this.

    My goal is to make large datasets in ONE table more readable by adding a visual component (font color) so that the user can easily identify records where he has to take some action. It’s important to mention that the conditions for formatting are variable from user to user. Example: User 1 Table 1: Sales > 100 => font green, User 1 Table 2: Sales > 35 => font green, User 2 Table 1: Sales > 10 => font green. The cutting values for green are calculated in the backend. They are available in a MySQL table.

    I thought there could be a solution by adding CSS or custom Javascript to a collumn. I saw that there is a “Code Manager Plugin” that is completing WP Data Access. Is there a solution by adding Javascript etc. with the Code Manager?

    Many Greetings
    Jorg

    • This reply was modified 2 years, 11 months ago by jorg2.
    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Jorg,

    >>> I thought there could be a solution by adding CSS or custom Javascript to a collumn.

    Here is an example using the Code Manager:
    https://wpdataaccess.com/docs/documentation/data-publisher/advanced-settings/#javascript-functions-more-complex

    You can also add a one liner to your publication advanced settings like this:
    “rowCallback”: “if (data[1] == ‘Z 800 E ABS’) { jQuery(row).find(‘td:eq(1)’).addClass(‘colorBlack’); } else { jQuery(row).find(‘td:eq(1)’).addClass(‘colorGreen’); }”

    Personally I prefer the Code Manager solution as this makes your custom code more readable and managable. But the choice is yours.

    Have a nice weekend ??
    Peter

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Conditional formatting’ is closed to new replies.