Responsive + TableTools sRowSelect - suppress details row click event

Responsive + TableTools sRowSelect - suppress details row click event

steve_at_ventussteve_at_ventus Posts: 18Questions: 5Answers: 0

Hi Allan,

This is a bit of an edge case. I have some DataTables with a "Batch Edit" mode where I toggle sRowSelect off and on via something like:

api.tabletools().fnSettings().select.type = type;

This part works great. I'm looking to prevent the toggling of Responsive details rows when a table has sRowSelect: 'os', as it is very distracting to be toggling details rows while trying to make a complex selection. I've tried to catch the event, ie:

$dt.on('click', 'tbody>tr', function( e ) { 
  e.preventDefault();
  e.stopImmediatePropagation();
});

I also tried to find a way to toggle the details row off and on via the API, and I came up empty. Another approach that would work, but I didn't see documented, is to trigger the display of the details row manually instead of with

 details: {
     type:  'column'
    ,target:    'tr'
    ,renderer:  responsiveDetailsRenderer
}

Do you have any insights on this?

Thanks,
-steve

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 48,908Questions: 1Answers: 7,133 Site admin
    Answer ✓

    The settings object is "private" (in the sense that it is visible, but shouldn't used publicly!) and writing changes to it is not something that is supported and might cause unexpected side effects.

    In this case, TableTools hasn't been designed to handle toggling the row selection - you could remove the event handler using $().off() but then you'd need to add it again in future if you want to toggle it back on. Either you could hack the library to add that feature, or

    Use the replacement to TableTools that I'm working on (imaginatively named Select). It haven't been released yet (I've still to write the documentation), but you are welcome to try it out if you like. Or if you hang on until next month it will be released as part of a major update to DataTables' extensions.

    Allan

  • steve_at_ventussteve_at_ventus Posts: 18Questions: 5Answers: 0

    Allan,

    I'm definitely willing to try "Select", even before public release. In the interim, I made a solution work by handling the details row myself (based on https://datatables.net/examples/server_side/row_details.html ), and manipulating the settings object.

    Thanks,
    -steve

This discussion has been closed.