How can I make a column not selectable?

How can I make a column not selectable?

jquijadojquijado Posts: 24Questions: 6Answers: 0

I have a DataTables object which draws a table and the left column includes an icon to deploy a row with extra info, just like in the example in https://datatables.net/examples/api/row_details.html and if Iuse the editor, a row is selected anywhere in the row I click. I'd like to make the left column (the one with the plus icon) not to select or deselect the row when clicked. This way, the row would be selected or deselected just if I click in any column but the left one.

The way I defined columns is like this:

"columns" : [
    {
        "className":        'celda_de_descripcion',
        "orderable":        false,
        "data":             null,
        "defaultContent":   '<div class="text-center fa fa-plus-circle" style="width:100%; color: #3dc728;"></div>'
    },
    {"data": 'nombre'},
    {"data": 'apellidos'},
    {"data": 'fecha_incorporacion'}, 
    {"data": 'salario_bruto_anual', className: "text-right"}
],
"order": [[1, "asc"]], 

Is this possible? Can I make a column be clicked without selecting its row?

Thanks a lot everyone.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,552Questions: 1Answers: 10,476 Site admin
    Answer ✓

    You can use the select.selector option to tell Select what elements in the row should trigger selection.

    This example shows selection on the first column only. Use :not(...) if you want the inverse of that.

    Allan

  • jquijadojquijado Posts: 24Questions: 6Answers: 0

    Thats correct, Allan. Thanks again.
    If I write, i.e.:

    select: {
        style: 'single', 
        selector: 'td:not(:first-child)'
    }, 
    

    It works properly. :)

This discussion has been closed.