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

Not able to do highlight selected row

Open osi-bhushankumar opened this issue 10 years ago • 8 comments

function rowCallback(nRow, aData) {
  $('td', nRow).unbind('click');
  $('td', nRow).bind('click', function () {
    $scope.$apply(function () {
      $scope.catalogs.someClickHandler(aData);
    });
  });
  return nRow;
}

I am able to grab value of selected row but not able to highlight s=that row using some background color.

osi-bhushankumar avatar Feb 02 '16 19:02 osi-bhushankumar

try adding a class after clicking the row.

function rowCallback(nRow, aData) {
   ...
   ...
   $(nRow).on('click', function (e) {
      $(nRow).addClass('highlight');
   });
   return nRow;
}

dashawk avatar Feb 04 '16 09:02 dashawk

I am trying to use more pure AngularJs rather than jQuery and core JavaScript. Is their possible to do this using ANgularJS ?

osi-bhushankumar avatar Feb 04 '16 09:02 osi-bhushankumar

Were you able to find an AngularJS method for doing this?

DonMorr avatar May 12 '16 10:05 DonMorr

You can use the DataTable extension select.

l-lin avatar May 14 '16 18:05 l-lin

@l-lin: how can I use the example of https://datatables.net/extensions/select/examples/api/select.html together with your angularjs-datatables ?

I like your style of displaying and reloading data, but I need the way to select rows of datatables.net.

Thanks

nemcuon avatar May 30 '16 13:05 nemcuon

See the documentation.

l-lin avatar May 31 '16 09:05 l-lin

Is a whole plugin really necessary just to highlight a selected row using an Angular approach??

metu avatar Jul 22 '16 12:07 metu

Here's another way:

Instead of using rowCallback, try using createdRow instead.

    config.withOption('createdRow', function (row, data, index) {
        row.setAttribute('ng-class', '{ highlight: YOUR_CONDITION }');
        row.setAttribute('ng-click', 'catalogs.someClickHandler(data)');
        $compile(row)($scope);
    })

YOUR_CONDITION should be set inside your someClickHandler().

dashawk avatar Aug 08 '16 01:08 dashawk