row colors...

row colors...

tyrrvktyrrvk Posts: 6Questions: 1Answers: 0
edited August 2009 in General
Hi all -
I have an extremely simply DataTables question - regarding a dynamically generated table (php). I've gotten the *.js files loaded, as well as the *.css. Some of the styles are being applied - for example table.display td.center
However, when I set my my rows do not get colorized. I am unclear why some of the styling is applying ok, and not the row colors. Does it have to do with the fact that PHP is looping through the returned table, and therefore Datatables cannot alternate between even and odd rows? If so, what's the solution?

[code]

echo '

EditFirst NameLast NamePayment StatusPaymentDate';
for ($i=0;$i<$num;$i++) {
$referenceID = mysql_result($result,$i, 'referenceID');
$firstname = mysql_result($result,$i, 'fname');
$lastname = mysql_result($result,$i, 'lname');
$status = mysql_result($result,$i, 'payStatus');
$amount = mysql_result($result,$i, 'payAmt');
$gmtime = mysql_result($result,$i, 'payDate');
echo 'Edit' .$firstname. '' .$lastname. '' .$status. '' .$amount. '' .$gmtime. '';
}
echo '';

[/code]

Replies

  • allanallan Posts: 61,726Questions: 1Answers: 10,109 Site admin
    Hi tyrrvk,

    I don't really see any reason why this wouldn't work if you have the correct CSS files included. Perhaps you could provide an link showing an example of the problem? Also, why "gradeA"? I used that as an example in my demos, because it makes sense for the data I am displaying, but in this case, all of your rows are going to have a class of "gradeA", so does it really need that class at all?

    Regards,
    Allan
  • tyrrvktyrrvk Posts: 6Questions: 1Answers: 0
    Hi Allan -
    Thanks for the response. Currently the page is locked down pretty heavily, so I can't share a link. However, I test the same page without the php code, and everything rendered correctly. However, the .php page refuses to assign row colors, even though other CSS elements seem to be applying correctly - for example, TH formatting, fonts.
    I dropped the TR classes on my .html page and everything worked like clockwork.

    thanks
  • tyrrvktyrrvk Posts: 6Questions: 1Answers: 0
    nevermind - I am completely missed something obvious - my intial tr tags were outside the thead fields:

    [code].
    03.EditFirst NameLast NamePayment StatusPaymentDate';[/code]

    moving them inside the thead tags fixed everything.
  • allanallan Posts: 61,726Questions: 1Answers: 10,109 Site admin
    Hi tyrrvk,

    Thanks for the update. DataTables can be quite strict about it's HTML, so it's already good to validate the page. Good to hear you got it sorted.

    Regards,
    Allan
This discussion has been closed.