Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing a column causes sorting by that column #30

Open
AlexeyKosov opened this issue Jul 15, 2020 · 3 comments
Open

Resizing a column causes sorting by that column #30

AlexeyKosov opened this issue Jul 15, 2020 · 3 comments

Comments

@AlexeyKosov
Copy link

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

@jacobSpitzer
Copy link

jacobSpitzer commented Mar 4, 2021

+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
Copy link

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
Copy link

arboeh commented Jul 1, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants