Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Please follow the Table cssClass options. In your case, you may define the function for td
. You will receive the $value and the $columnName as parameter. Base on them, you can decide the cssClass for the cell. Then you should have your own definition like color of text or background for your own style.
I am sorry I don't understand clear what do you mean saying "I’m using server side. It’s not applying the style."
My example cannot help you even i give you my css file
You must use the code above in your view file this way:
...
<?php
Table::create(array(
"dataStore" => your datastore
"columns" => array( your columns)
"cssClass" => array(
"table" => "table table-hover table-bordered",
"td" => function ($row, $columnName) {
if ($columnName == "totalCost" && $row["totalCost"] == 0) { //CHANGE TO YOUR LOGIC HERE
return "noprice";
} else {
return "";
}
}
),
...
));
?>
and add the corresponding style for the noprice
HTML class in your css file.
Thank you Eugene.
So what I have is this:
"serverSide"=>true,
"method"=>'post',
"columns"=>array(
At the moment, I'm resorting to:
"options"=>array(
"paging"=>true,
...
"rowCallback" => "function(row, data, index) {
if (data.region == 'APJ') {
$('td:eq(0)', row).addClass('yellow');
}
What does not work is this:
"cssClass" => array(
"table" => "table table-hover table-bordered",
"td" => function ($row, $columnName) {
if ($columnName == "region" && $row["region"] == 'APJ') {
return "yellow";
} else {
return "";
}
}
),
What I meant before is that somehow I don't see cssClass do anything.
Thanks again!
eMax, I see that you used DataTables' serverSide processing which would nullify cssClass' td. However you can still use either options' rowCallBack or cssClass' tdJs client-side function as documented here:
https://www.koolreport.com/docs/datagrid/datatables/#set-custom-css-classes
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo