Zebra-striping overrules my classes - but only in odd rows...

Zebra-striping overrules my classes - but only in odd rows...

mibaasmibaas Posts: 19Questions: 0Answers: 0
edited April 2014 in General
I have a date-column in my table and am assigning styles to these cells (using fnCreatedCell with $(nTd).addClass(..) - for all cells.
But unfortunately the table only shows the styles in even rows, the odd rows are shown in zebra-color.

My CSS is built like this:

[code]tr.odd td.dateClass0 { background-color: #ff0909 !important; }
tr.even td.dateClass0 { background-color: #ff0b0b !important;}[/code]

so in in theory it is all in place. And when I sort the table (so that odd rows come into even places), they then show the correct style there, yet the then-odd rows are only zebra-odd.

Checked with IE9 and FF27. When I look at these cells with the WebDev-extension in FF, the odd cells show the correct class being assigned (in the code), but the "Rule"-view (right panel in inspector) does not show my CSS being used. That's different from the even rows. What kind of magic is going on there? ;-)

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Can you link us to the page so I can inspect it? I can't really say at the moment other than suggesting that there is a CSS priority issue - but you already knew that! The dev tools in Chrome and Firefox should show what is overriding your style.

    Allan
  • mibaasmibaas Posts: 19Questions: 0Answers: 0
    Unfortunately it's on an intranet and it is so locked away that I can not even get files out from there :((
    The strange surprise with DevTools is that they do not show any of my CSS, not even in the usual strike-through for overwritten stuff - it's not there at all! But only for the odd rows.
  • mibaasmibaas Posts: 19Questions: 0Answers: 0
    In FF's inspector, when I change the class of odd rows to even, they also show my styles being applied.

    So, is there anything special you do with odd rows (any JS-events etc. or so)?
  • mibaasmibaas Posts: 19Questions: 0Answers: 0
    Found another very surprising detail: there is one custom class which IS being applied in odd and even rows! So I edited my CSS and moved the declaration of non-applied classes to the area where this class was declared (assuming the sequence might have been relevant), but it was not. I'm totally out of idea now. So I will go through that painfull process of extracting HTML and getting it through the gateway tomorrow so you can have a look at it...
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    > So, is there anything special you do with odd rows (any JS-events etc. or so)?

    Nope. This is the CSS DataTables uses (v1.10 - 1.9 has something similar): https://github.com/DataTables/DataTables/blob/master/media/css/jquery.dataTables.css#L95 (and the following lines for more complex operations).

    The CSS inspector in Chrome is superb. It will tell you where the styles are coming from. That's all I would do if you gave a link - just fire up Chrome's inspector.

    Allan
  • mibaasmibaas Posts: 19Questions: 0Answers: 0
    Allan, I have finally got the stuff boiled down, out of the intranet and onto my webserver, so you can have a look at that thing here: http://mbaas.de/dataTables/zebra-styling-odd-rows.htm
  • mibaasmibaas Posts: 19Questions: 0Answers: 0
    Oooops - only after posting I saw your last comment. Also had a look at that page with Chrome which also reproduced the problem. But did not get any clues from its inspector :(
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Which cell specifically is in error? Is it the Fallig column? The reason I'm not sure is that the purple shows in the cells for the top four cells.

    Allan
  • mibaasmibaas Posts: 19Questions: 0Answers: 0
    Sorry, I left out the precise description and instruction: indeed that 2nc column "Fällig" exposes the problem - in all but the "OverDue"-styled cells. Have a look at line 6 with date "09.04.2014" - this cells has the same class as the rows above and below, so it should be red! The style from column "CSS" will be assigned to the cells using fnCreatedCell. So if you use the ColumnFilterWidget "CSS" and select "dateClass0", you will see rows where the 2nd cell has dateClass0...
    Alternatively, play with sorting etc. to make line 6 show up in an even row and you will see that cell becoming red...
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Your CSS has:

    > tr.even td.dateClass0

    Now - perhaps I'm not getting something, but that looks like it is targeting only `even` rows to me...

    Allan
  • mibaasmibaas Posts: 19Questions: 0Answers: 0
    Oh no! Well, I certainly also had td.even covered - but I ruined it all with some //-comments that caused errors :(((

    Don't know how much I looked at these lines - but I never noticed these comments were wrong! :((

    Thank you so much!
This discussion has been closed.