Closed forexknight closed 5 years ago
To my knowledge DataTables itself does not natively support this, and requires dirty hacks to achieve this result, judging by https://datatables.net/forums/discussion/46697/adding-a-class-to-a-row-on-datatables-initialization from this year.
This bundle is however completely unopinionated on your clientside code so you could relatively easily add the same workaround they did in your frontend code.
Not something we can really handle generically serverside so considering closed, this is clientside customization and therefore out of scope for the bundle.
@forexknight it's quite simple to do without hacks. Let's say you have an order_status data column in the grid. Put this in your view on the client side:
` $( document ).ready(function() {
$('#mytable').initDataTables({{ datatable_settings(datatable) }},
{
"rowCallback": function( row, data, index ) {
console.log (data);
jQuery(row).addClass("order-status-" + data.order_status.toLowerCase());
}
}
);
});`
Hi,
at the beginning thank you for developing this useful plugin. I want to know if there is an option to ### add html class to table row depending on a field from entity class? I was looking in the documentation but I only found that I can addClass directly to the column, but I have to hilight whole row element and would like to avoid adding className to each column.
Thanks!