UnSelectable Rows in Jquery DataTable?

UnSelectable Rows in Jquery DataTable?

AkilaAkila Posts: 1Questions: 1Answers: 0

Hi,
On Some button click, i want to view some rows in data table are unselectable or unclickable(i.e disable) and other rows are selectable like that.

Thanks in Advance,

Answers

  • RpiechuraRpiechura Posts: 98Questions: 3Answers: 14

    Just to be clear, you actually do mean row (horizontal) and not column (vertical) correct? Assuming that's what you want and you're doing the selection of rows like the example at http://datatables.net/examples/api/select_row.html than you can do something like

    $('#example tbody').on('click', 'tr', function () {
        if (this.rowIndex > 5) {
    
        }
        else {
               $(this).toggleClass('selected');
        }
    } );
    

    That code will basically make it so that you can only select the first 5 rows of the table. Obviously you can get more complicated with the logic, but hopefully that gives you an idea of where to go.

This discussion has been closed.