Question v0.4.3: how to get several selected rows
Dear all,
with the .withOption('select', true) I can select multiple rows, using Ctrl or Shift, because it would enable the underlying jquery datatable's Select plugin https://datatables.net/extensions/select/
Now the question is: how can I get the selected rows ?
I know that the methods mentioned at https://github.com/l-lin/angular-datatables/issues/21 are deprecated (no dt-rows nor TableTools is supported with version 0.4.3), and I know that the angular-datatables method
withOption('rowCallback', function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {}
can only work with one row. A pity !.
Thanks,
According to the DataTable's documentation, you can fetch the data of the selected rows by calling table.rows( { selected: true } ).data();.
One example:
<button ng-click="showCase.doSomethingWithSelectedRows()>
Do something with selected rows
</button>
<table datatable dt-options="showCase.dtOptions" dt-instance="showCase.dtInstance">
</table>
vm.dtOptions = DTOptionsBuilder.fromSource('data.json');
vm.dtInstance = {};
vm.doSomethingWithSelectedRows = function() {
var data = vm.dtInstance.DataTable.rows( { selected: true } ).data();
// You do your thing
};
Thanks Louis,
.data() is the one I have been looking for.