ColReorderWithResize icon indicating copy to clipboard operation
ColReorderWithResize copied to clipboard

Resizing a column causes sorting by that column

Open AlexeyKosov opened this issue 4 years ago • 3 comments

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

AlexeyKosov avatar Jul 15 '20 15:07 AlexeyKosov

+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.

jacobSpitzer avatar Mar 04 '21 03:03 jacobSpitzer

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);
	});
});

SpikedCola avatar Apr 19 '21 21:04 SpikedCola

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

arboeh avatar Jul 01 '21 05:07 arboeh