Get selected row value?
I am trying to figure it out how to find out selected row value. For example, one of my table column has an ID and I want to return it after selecting the selected row(s). I can't see how to get it in your angular version. Could you point me in the right direction if that is even possible?
You can resolve your problem with one of those possible solutions:
- Using JS
- Using the TableTools plugin:
$scope.dtOptions = DTOptionsBuilder.fromSource('data.json')
.withTableTools('https://github.com/DataTables/TableTools/raw/master/swf/copy_csv_xls_pdf.swf')
.withTableToolsOption('sRowSelect', 'single')
.withTableToolsOption('fnRowSelected', function(nodes) {
// Do something about your row
});
- Using angular
ng-clickdirective with the "Angular way" of rendering your DataTable:
<table datatable="ng" dt-options="dtOptions" dt-columns="dtColumns">
<thead>
<tr>
<th>ID</th>
<th>FirstName</th>
<th>LastName</th>
</tr>
</thead>
<tbody>
<tr dt-rows ng-repeat="person in persons" ng-click="doSomething(person.id)">
<td>{{ person.id }}</td>
<td>{{ person.firstName }}</td>
<td>{{ person.lastName }}</td>
</tr>
</tbody>
</table>
is this still working?
.withOption('fnRowSelected', function(nodes) {
// Do something about your row
});
Somehow I cannot make it work.
It's .withTableToolsOption, not .withOption. Careful :smile:
It's .withTableToolsOption, not .withOption.
I thought TableTools were deprecated. :open_mouth:
TableTools is deprecated and dt-rows does not exist anymore at least for v0.4.3
How can we do this in the latest version ? I am using the select extension, but not sure how to get the selected values.