You should use a custom init script than the one provided. Here's an example of mine used to add tooltip hovers to links.
$('.dataTable').each(function () {
var table = $(this);
var model = table.attr('data-model');
var settings = model ? dataTableSettings[model] : {};
settings.sDom = "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>";
settings.sPaginationType = "bootstrap";
settings.aoColumnDefs = [
{ "sClass": "actions", "aTargets": [ -1 ] } // adds "actions" class to the last column
];
settings.fnDrawCallback = function (oSettings) { // called when the table is drawn, page changed
initTooltip(this);
};
table.addClass('table table-bordered table-striped').dataTable(settings);
});
The js var dataTableSettings is generated by the plugin for the columns. We grab that and extend it to whatever we need.
In your controller, change your helper definition to:
public $helpers = [
'DataTable.DataTable' => ['scriptBlock' => false],
];
Hi,
I'm using your plugin for showing a list products. I'm using helper to render table. For now, I want to add class attribute to
One more question, how can I add my callback functions after a row/table is drawed?
Thanks so much.
You should use a custom init script than the one provided. Here's an example of mine used to add tooltip hovers to links.
The js var
dataTableSettings
is generated by the plugin for the columns. We grab that and extend it to whatever we need.In your controller, change your helper definition to:
Yes, Thanks.
I also want to set different colors for table rows that depend on value of any field in data model. Could I?
Thanks again.
You can through callbacks in the js lib. I don't provide support for that. Go to the datatables page and look through the documentation.
Specifically http://www.datatables.net/examples/advanced_init/row_callback.html