select row by passing a datatable id (Jquery)

0

I'm working with jquery datatable. I would like to be able to select a row (Add the classe seleted) but passing it an id.

Let me explain, when I click on a row, it is shaded, I want it to do that but without clicking, for example, passing it an id of the row.

This is the code

tblProyectosFueraPlazo.on('init', function () {      
            var rowToSelect = '#row_' + '0';
            tblProyectosFueraPlazo.row(rowToSelect).select();
        });
    
asked by Lorenzo Martín 19.11.2018 в 18:40
source

1 answer

1

To select the row number x , you use the selector eq (x). Example to select row 2 and add the selected class:

$('#tblProyectosFueraPlazo tr').eq(2).addClass('selected');

Greetings

    
answered by 20.11.2018 / 11:32
source