Override Order

Override Order

srailsbacksrailsback Posts: 4Questions: 2Answers: 0

Is there a way to prevent ordering of a column on click? I have an icon next to each column header. Clicking the icon triggers a bootstrap popover that displays information about the column. This event also sorts the column. The desired behavior is to prevent sorting when the icon is clicked.

Answers

  • srailsbacksrailsback Posts: 4Questions: 2Answers: 0

    Answer is fnPreDrawCallback, here's the jsfiddle
    https://jsfiddle.net/srailsback/q7hjco9k/

    $('#example').DataTable( {
    "fnPreDrawCallback": function( oSettings ) {
    if ($(event.target).data('toggle') === 'popover') {
    return false;
    }
    }
    });

  • allanallan Posts: 63,871Questions: 1Answers: 10,526 Site admin

    Is there a way to prevent ordering of a column on click

    columns.orderable.

    Allan

  • srailsbacksrailsback Posts: 4Questions: 2Answers: 0
    edited January 2016

    The columns should be orderable. It's only when the icon is clicked that I want to prevent ordering. The jsfiddle shows an example.
    Thanks for the reply Allan!

  • allanallan Posts: 63,871Questions: 1Answers: 10,526 Site admin

    Oh I see - thanks for the clarification. You could attach an event listener to the icon and then use e.stopPropagation() to stop the event bubbling up to the DataTables event listener.

    I'm afraid that is really the only good option at the moment. However, I realise that this is a bit of a pain point and plan to introduce updates later this year which will help to resolve it.

    Allan

This discussion has been closed.