jeffreydwalter / ColReorderWithResize

Column reordering and resizing plug-in for DataTables
http://www.datatables.net/
MIT License
42 stars 51 forks source link

Resizing a column causes sorting by that column #30

Open AlexeyKosov opened 4 years ago

AlexeyKosov commented 4 years ago

When a resize is finished, a "click" event is triggered, which causes a resorting for the column. Is it possible to avoid it?

jacobSpitzer commented 3 years ago

+1 The funny part is, that only when I move the column to the left side - to make the column smaller - is causing the sort/refresh. But, when I move it right - is it working good.

SpikedCola commented 3 years ago

If it helps, I was able to work around this issue like this:

var resizing = false;
jQuery(document).ready(function() {
    jQuery('#table th').on('click.DT', function(e) {
        // if we have just resized, prevent datatables sort handler from running.
        if (resizing) {
            e.stopImmediatePropagation();
        }
    });
    jQuery('#table').on('column-resize.dt.mouseup', function() {
        // set global flag that we have just resized.
        resizing = true;
        // and clear after some small amount of time.
        setTimeout(function() { resizing = false; }, 100);
    });
});
arboeh commented 3 years ago

Same problem for me an fix from SpikedCola fixes it. Thanks!