How do you make several columns in table view readonly when you have inline editing enabled?

How do you make several columns in table view readonly when you have inline editing enabled?

rmeetinrmeetin Posts: 100Questions: 24Answers: 1

Is there a way to make several columns read-only in table view using columnDefs or other? Something like:

{ targets: [ 1,2,3 ],
render: 'readonly';
}

or

{ targets: [1,2,3],
render: function( data, type, row ) {
return something;
}
},

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Is this using inline editing? If so, it would be jQuery selector used there that would determine if it's readonly. You could add styling to show that with columns.className,

    Colin

  • rmeetinrmeetin Posts: 100Questions: 24Answers: 1

    $('#example').dataTable( {
    "columnDefs": [
    { className: "my_class", "targets": [ 2,3,5,6 ] }
    ]
    } );

    I see this but how do you make it read-only?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    As I mentioned, you would use the selector for inline editing, see here,

      $('#example').on('click', 'tbody tr td:not(:nth-child(2), :nth-child(3))', function() {
        editor.inline(this);
      }); 
    

    Colin

This discussion has been closed.