Alternating row colors doesn't occur despite consistent formatting between pages.

Alternating row colors doesn't occur despite consistent formatting between pages.

totallyplandomtotallyplandom Posts: 27Questions: 1Answers: 1
edited October 2011 in DataTables 1.8
Hi All,

I'm having a bit of quirky behavior out of DataTables. Basically I have some tables for which "alternating row colors" does not occur. Is there any completely obvious reason this would fail? I'm using the EXACT SAME CSS for all tables, they simply contain different data. It just seems that DT randomly decides that some tables shouldn't use alternating row colors.

Best.

Replies

  • H2wkH2wk Posts: 14Questions: 0Answers: 0
    Are you using correct css references on all your pages?

    Are you using jquery theming?
  • GregPGregP Posts: 500Questions: 10Answers: 0
    There's always a logical explanation for this kind of thing. If you're using CSS to apply striping directly (ie. nth-child in CSS rule) then it might be about specificity or some other sort of conflict, whereby another rule is getting precedence. If it's about using row classes "odd/even" for the striping, it could also be a CSS conflict, OR it could be that the classes are not getting applied and/or they are applied and then somehow stripped by a different function.
  • totallyplandomtotallyplandom Posts: 27Questions: 1Answers: 1
    @H2wk: Yes, I do have correct CSS references. All files are in a flat directory so the reference is the same. Basically the CSS is a single "class" reference that I use if there is no JS enabled. If JS is enabled, I remove the class with JQuery, and use JQuery Theming (the default theme). For some pages this works, for some it doesn't.

    @GregP Since the alternating "even/odd" row class designations are dependent on being below the "class" my CSS shouldn't matter at this point -- and in fact I removed it completely just to test. Still the same inconsistent behavior.
  • GregPGregP Posts: 500Questions: 10Answers: 0
    I'm not sure what you mean by "being below"; order of CSS only matters with selectors with the same specificity. Otherwise there's a whole inheritence and priority chain that's followed. But it IS a CSS matter even if indirectly (failure in JavaScript is disallowing the CSS rules, for example): when you say "DT randomly decides that some tables shouldn't use alternating row colors", it could be anything related to the CSS:

    1. Some tables are not having "even" and "odd" applied to their rows. Look in Firebug or Dev Tools. Do the rows have a class?

    2. If so, still in Firebug/Dev Tools, can you see if the "even" or "odd" color styles are "crossed out" (meaning CSS with more priority has taken over)

    3. If the rule is "crossed out", and you don't see any other declared CSS rules that have priority, can you see any inline styles being applied? (usually this is JavaScript applying "background-color: #whatever" and inline styles DO have higher priority all things considered).

    There will be some sort of culprit. DT doesn't have a fickle personality; the page just runs the code it's told to.
  • totallyplandomtotallyplandom Posts: 27Questions: 1Answers: 1
    Hey GregP,

    Thanks. Yes, I'm aware that DT shouldn't be fickle, per se. However, I was using "randomly" to denote that I have, as yet, been unable to track it to a specific cause -- there's no consistency -- given that all pages use the same code (but not data). Perhaps it's choking on some text/number formatting in a particular table.

    As far as "being below" is concerned, I meant "contained within". Only class "row"s that are below (or contained within) class "awesome table" should be changed. Any occurrences of "row" not contained within an "awesome table" shouldn't be affected. You know, hierarchically "below".

    Anyway, I'd been working primarily in Safari, but I verified that the same errors occur in FF, and IE on Windows. I'll check Firebug and post back if/when I have more info.

    Thanks again.
  • GregPGregP Posts: 500Questions: 10Answers: 0
    Not a problem. I hope I don't sound too bullheaded! If you have a link for me to help dig in, let me know.
This discussion has been closed.