ericcron
Založený: 07.05.2004
Príspevky: 3
Zaslal: 2004-05-07 20:17
Návrat hore
Odpovedať s citátom
|
Just wondering if it's possible to change the row color based on the contents of a particular field.
Thoughts? Thanks for any suggestions.
Eric
|
nepto
Založený: 06.01.2003
Príspevky: 381
Bydlisko: Phoenix, Arizona (USA)
Zaslal: 2004-05-10 23:44
Návrat hore
Odpovedať s citátom
|
This is actually work in progress:
http://opensource.platon.sk/projects/bug_view_advanced_page.php?f_bug_id=157
_________________ Ondrej Jombik (Nepto)
Visit my
homepage
, review my recent
CV
or
projects
and give me some
feedback
.
|
hbernard
Založený: 23.03.2003
Príspevky: 159
Bydlisko: FRANCE
Zaslal: 2004-05-16 14:53
Návrat hore
Odpovedať s citátom
|
ericcron Napísal: |
Just wondering if it's possible to change the row color based on the contents of a particular field.
Thoughts? Thanks for any suggestions.
Eric |
Well, nepto pointed out the correct bug report.
However, I think this is currently doable, using css options. (for the list mode)
$opts[’css’][’divider’] = 2; is PME default.
rows are outputted with css class like this :
row-......-0
row-......-1
row-......-0
row-......-1
row-......-0
If you use
$opts[’css’][’divider’] = 10000; (or any large number)
you have distinct class for all rows.
Then, you will need to ouput specific hidden css style for each row, using 'sql' for example.
Just an idea... But this should work.
_________________ hbernard - phpMyEdit updater.
|
ericcron
Založený: 07.05.2004
Príspevky: 3
Zaslal: 2004-05-20 14:27
Návrat hore
Odpovedať s citátom
|
Hi there,
thanks everybody for the responses. I think the first reply - applying style conditionally - almost does the trick. But - I would need a little more logic.
We have 2 fields, start and stop. I need to change the style of both fields if the current date falls between these two dates in start and stop.
In English,
If (todays.date >= Start) && (todays.date <= Stop)
change both start and stop to bold.
Looks like it could happen, I just don't know the syntax :)
Thanks again, phpmyedit is a great product -
Eric
|
ericcron
Založený: 07.05.2004
Príspevky: 3
Zaslal: 2004-05-20 17:52
Návrat hore
Odpovedať s citátom
|
Thanks Doug -
This appears to be working now...
Kód: |
$opts['fdd']['Start']['escape'] = false;
$opts['fdd']['Stop']['escape'] = false;
$opts['fdd']['Start']['sql|LF'] =
'if( "'.date("Ymd").'" >= Start AND "'.date("Ymd").'" <= Stop ,
CONCAT("<span style=\"color:#ff0000\">",
Start,
"</span>"),
Start )';
$opts['fdd']['Stop']['sql|LF'] =
'if( "'.date("Ymd").'" >= Start AND "'.date("Ymd").'" <= Stop ,
CONCAT("<span style=\"color:#ff0000\">",
Stop,
"</span>"),
Stop )';
|
But now the "highlighted" records don't sort properly, they always appear at the end of a list in ascending, or at the top of decending.
Anybody have any thoughts about why it would throw off the sort order?
|
chuny30
Založený: 13.04.2003
Príspevky: 6
Zaslal: 2007-12-19 01:23
Návrat hore
Odpovedať s citátom
|
What would be the reason why the contents of the CONCAT is being treated as a text string rather than html? The entire <span style....</span> is being displayed as is rather than the just the color code
doug Napísal: |
On a cell by cell basis you can conditionally apply style. This example compares today's date with the column named start_date. Dates in the past appear using red font color.
Kód: |
$opts['fdd']['start_date']['sql|LF'] =
'if( start_date < "'.date("Ymd").'",
CONCAT("<span style=\"color:#ff0000\">",
start_date,
"</span>"),
start_date )'; |
|
|
chuny30
Založený: 13.04.2003
Príspevky: 6
Zaslal: 2007-12-19 02:52
Návrat hore
Odpovedať s citátom
|
Thanks Doug. Would it be possible to add an else clause in there as well?
doug Napísal: |
oops .... forgot this
|
|
chuny30
Založený: 13.04.2003
Príspevky: 6
Zaslal: 2007-12-19 03:04
Návrat hore
Odpovedať s citátom
|
Should have been more specific, apologies. What I wanted was in your example of date comparison, would it be possible to change the color if the condition was met, but if not change the color to green or something?
doug Napísal: |
chuny30 Napísal: |
Would it be possible to add an else clause in there as well? |
Huh? |
|
pierig
Založený: 15.04.2009
Príspevky: 3
Zaslal: 2009-04-15 16:01
Návrat hore
Odpovedať s citátom
|
I have the same issue as "ericcron". In fact I have a list with bugs of a software we use and every row which includes "yes" in the field "Solved" should have another color than the "no" row.
The solution here just makes you the color of the textbackground and just one column. If you put the code for all fields it's looking acceptable, but sorting is not working properly.
I know it's an old story, but I'm searching since two days in your forum. I really like phpmyedit, please help me!
Naposledy upravil pierig dňa 2009-04-15 19:27, celkom upravené 1 krát
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2009-04-15 17:55
Návrat hore
Odpovedať s citátom
|
I don't have an answer for you, but do you really have a field named "Solved?" with a question mark in the field name? If so, that might be part of the sort problem. Punctuation might be legal for column names (no time to research that) but actually using punctuation other than underscore with MySQL field, table, or db names can cause all sorts of unexpected problems.
|
pierig
Založený: 15.04.2009
Príspevky: 3
Zaslal: 2009-04-15 19:31
Návrat hore
Odpovedať s citátom
|
Thanks doug for the quick answer.
Unfortunetly or fortunetly there's not question mark, I just did as usual, sorry.
I guess I really have the same issue as ericcron, so I thought there must be a logical reason..
Thanks for helping
|
pierig
Založený: 15.04.2009
Príspevky: 3
Zaslal: 2009-04-20 10:38
Návrat hore
Odpovedať s citátom
|
bump
|
amvarani
Založený: 22.12.2009
Príspevky: 5
Zaslal: 2009-12-22 12:50
Návrat hore
Odpovedať s citátom
|
I have the same 'sorting' problem here...
Any solution ?
|
jc8458
Založený: 23.09.2010
Príspevky: 2
Zaslal: 2010-09-23 21:47
Návrat hore
Odpovedať s citátom
|
Has anyone found a solution to this?
|
tbarmann
Založený: 22.06.2011
Príspevky: 1
Zaslal: 2011-06-22 21:54
Návrat hore
Odpovedať s citátom
|
This is an old thread, but I have found a simple solution using jQuery, a Javascript library, and am posting in the hopes that it will help others.
I had a phpmyedit table list view that contained a field with either a value of "Active" or "Cleared". I wanted to highlight in red any row that contained "Active."
All that's required is this jquery code in the head section of your page:
Kód: |
<script type="text/javascript">
$(document).ready(function () {
$('.pme-main tr').find('td:contains(\"Active\")').siblings().css('backgroundColor', 'red');
$('.pme-main tr').find('td:contains(\"Active\")').css('backgroundColor', 'red');
});
</script> |
This searches through all table rows and looks for any cell that contains the word "Active." It then changes the backgroundcolor css value for its siblings (all the other <td>s in that row.) The second line changes the background color of the cell itself.
Note - The first code snippet I tried changed the background color of the parent <tr>. But that didn't work as I was using a css stylesheet that defined the background color for each cell, so it took precedence over the css of the parent.
Of course, you'll need to include a call to jquery in your table editing file. This example pulls in the latest version from jquery.com. You may want to use another source, or just download your own copy and store it on your server.
Kód: |
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> |
This solution also does not interfere with phpmyedit column sorting.
ericcron Napísal: |
Just wondering if it's possible to change the row color based on the contents of a particular field.
Thoughts? Thanks for any suggestions.
Eric |
|
Odoslať novú tému
Odpovedať na tému
Choď na stránku 1, 2 Ďalší
|