row grouping - display other columns
row grouping - display other columns
mmontoya
Posts: 84Questions: 27Answers: 4
I am using the sample provided for row grouping but I need to show more data from the table in that row.
"drawCallback": function ( settings ) {
var api = this.api();
var rows = api.rows( {page:'current'} ).nodes();
var last=null;
api.column(1, {page:'current'} ).data().each( function ( raNum, i ) {
if ( last !== raNum ) {
$(rows).eq( i ).before(
'<tr class="group"><td colspan="4">'+raNum+'</td></tr>'
);
last = raNum;
}
} );
}
I have some other columns defined:
{data: "OCNumber", title: "OCNumber"},
{data: "OldRANumber", title: "Old RA #" },
and would like to add those as well:
'<tr class="group">
<td>'+raNum+'</td>
<td>'+OCNumber+'</td>
<td colspan="2">'+OldRANumber+'</td>
</tr>'
but not sure how to reference those values in the callback function.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
aha!! Not sure if this is the best way but it works :)
Hello,
what is
table
in this line:var data = table.row(i).data();
?
edit: nevermind, I accessed the row via rows as per example https://datatables.net/examples/advanced_init/row_grouping.html
besides, I need grouping by multiple columns, not just displaying another column.