dinamic order attribute for sorting
dinamic order attribute for sorting
kirillos
Posts: 1Questions: 1Answers: 0
Hi! Sorry for my bad inglish.
My data table init from html
<table id="table_id">
<thead>
<tr>
<th>rank</th>
<th>name</th>
</tr>
</thead>
<tbody>
<tr>
<td data-order="1">1</td>
<td>name1</td>
</tr>
<tr>
<td data-order="2">2</td>
<td>name2</td>
</tr>
</tbody>
</table>
and js
table_on_h = $('#table_id').DataTable({
scrollX: true,
paging: false,
searching: false,
ordering: true,
info: false,
autoWidth: false,
columnDefs: [
{
targets: 0,
width: 80,
orderable:true
},
{
targets: 1,
width: 165
}
],
fixedColumns: {
leftColumns: 2,
rightColumns: 1
}
});
Then i load data from ajax, like that
var arrayOfData = ['3', 'name3'];
var rowNode = table_on_h.row.add(arrayOfData).draw().node();
Elements in arrayOfData is custom html code.
How add order value to loaded td?
This discussion has been closed.
Answers
Hi @kirillos ,
You can use
createdRow
orrow().node()
to manipulate the row and add the ID.See an example here.
Cheers,
Colin