Conditional CSS in a date column

QuestionsConditional CSS in a date column
E Mello asked 9 years ago

Hi,
I have been using conditional_css and I came across a challenge.
I have one hidden date column that is used to compare today's date:

SELECT due_date, (due_date,'%Y%m%d') as due_date_grid FROM…

I want to set the column background green if is due or red if overdue.
I can set the background column on the hidden column using the following lines:

$f = array();
$f["column"] = "due_date_grid";
$f["op"] = ">=";
$f["value"] = date("Ymd");
$f["cellcss"] = "'background-color':'#aae4a7', 'color':'black'";
$f_conditions[] = $f;

But I want to set the color on the "normal" due date column, not the hidden one. Because the hidden one shows as yymmdd and my due date column is the display one: dd/mn/yyyy.

If I do that:

$f = array();
$f["column"] = "due_date_grid";
$f["op"] = ">=";
$f["value"] = date("Ymd");
$f["css"] = "'background-color':'#aae4a7', 'color':'black'";
$f_conditions[] = $f;

It sets the background for the whole row, I don't want that.

Any ideias?

Many thanks.

4 Answers
Abu Ghufran answered 9 years ago

You can also have extended conditional formatting using JS code.
Refer faq: How to apply formatting of rows, based on 2 or more fields. http://phpgrid.org/faqs

I've also emailed you a demo grid code

E Mello answered 9 years ago

Thanks for your help.
That solution works.

Abu Ghufran answered 9 years ago

I've verified on Firefox 43.0.1, that demo cell formatting works as expected.
(I can't run your emailed demo coz of missing database)

In any case, you might need to hack css using debugger and override the conflicting style.

E Mello answered 9 years ago

Hi Abu,

You sent this code to me as suggestion for an advanced conditional formatting.

It works os Google Chrome.
For my surprise, it does not work in IE 10 and also Firefox.
The cell background color remains with no color.

What do you suggest me to do?

Thanks,

Emerson

Your Answer

8 + 19 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?