angular-datatables icon indicating copy to clipboard operation
angular-datatables copied to clipboard

Get selected row value?

Open ghost opened this issue 12 years ago • 6 comments

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?

ghost avatar Jul 11 '14 11:07 ghost

You can resolve your problem with one of those possible solutions:

$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-click directive 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>

l-lin avatar Jul 11 '14 12:07 l-lin

is this still working?

  .withOption('fnRowSelected', function(nodes) {
    // Do something about your row
  });

Somehow I cannot make it work.

jmelosegui avatar Feb 08 '16 15:02 jmelosegui

It's .withTableToolsOption, not .withOption. Careful :smile:

l-lin avatar Feb 08 '16 17:02 l-lin

It's .withTableToolsOption, not .withOption.

I thought TableTools were deprecated. :open_mouth:

jmelosegui avatar Feb 09 '16 16:02 jmelosegui

TableTools is deprecated and dt-rows does not exist anymore at least for v0.4.3

nemcuon avatar May 31 '16 08:05 nemcuon

How can we do this in the latest version ? I am using the select extension, but not sure how to get the selected values.

alwinaugustin avatar Sep 22 '20 09:09 alwinaugustin