I have a jQuery datatable row:
table = $('#reports').DataTable()
row = table.row(rowIndex)
How do I get the HTML class from it? (It is striped, and I want to find out if it is odd or even.)
I have tried:
row.hasClass('odd')
row.className
row.attr('class')
Any ideas?
The row selector is a component that acts like a visual filter for datasets. It takes one dataset, chops it up into various ranges based on its configuration, and lets the user choose the splices. Then it creates a virtual dataset that only contains the rows that match the selected splices.
$(this). closest('tr'). children('td:eq(0)'). text();
Description. This callback allows you to 'post process' each row after it have been generated for each table draw, but before it is rendered into the document. This means that the contents of the row might not have dimensions ( $(). width() for example) if it is not already in the document.
Introduction to jQuery Data Table jQuery DataTable is a powerful and smart HTML table enhancing plugin provided by jQuery JavaScript library.
To use DataTables, the first step is to include the jQuery library since it is a jQuery plugin. Secondly, two additional files need to be included to get DataTables running on your website.
It supports both client-side processing as well as server-side processing. To use DataTables, the first step is to include the jQuery library since it is a jQuery plugin. Secondly, two additional files need to be included to get DataTables running on your website.
Refresh the index.html document in your browser, and click on the Test Button input; the get object by class is activated, and the result is shown in Figure C as displayed in Chrome 17.0.9:
Use node
with className
:
row.node().className;
It is a really a good question. The ordinary jQuery way, by using row.index()
:
var rowClass = $("#example tbody tr:eq(" + row.index() + ")").attr('class');
Proof of concept -> http://jsfiddle.net/7jy46wz4/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With