Not able to do highlight selected row
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.
try adding a class after clicking the row.
function rowCallback(nRow, aData) {
...
...
$(nRow).on('click', function (e) {
$(nRow).addClass('highlight');
});
return nRow;
}
I am trying to use more pure AngularJs rather than jQuery and core JavaScript. Is their possible to do this using ANgularJS ?
Were you able to find an AngularJS method for doing this?
You can use the DataTable extension select.
@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
See the documentation.
Is a whole plugin really necessary just to highlight a selected row using an Angular approach??
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().