datatables-bundle icon indicating copy to clipboard operation
datatables-bundle copied to clipboard

ColReorder plugin dosn't work corrent

Open valeriy-efimov opened this issue 3 years ago • 4 comments

I'm try to use this https://datatables.net/extensions/colreorder/examples/integration/server_side.html But on server side got wrong column order and individual search. If I swap first and second column and try to order first datatables-bundle sorted by default first.

valeriy-efimov avatar Apr 20 '22 17:04 valeriy-efimov

I'm actually surprised this doesn't work correctly, as I would expect the plugin to handle this completely inside DataTables itself.

Do you have concrete information on what is broken and how?

curry684 avatar Aug 18 '22 08:08 curry684

Hi @curry684 this trick resolved bug but I think it's a crutch.

		this.datatable.on('preXhr', function(e, settings, details) {
			let columns  = Object.values(
				Object.assign({}, settings.aoColumns));
			columns      = columns.sort(function(a, b) {
				return a.index - b.index;
			});
			let original = [];
			columns.forEach((element) => {
				original.push(
					details.columns.find(x => x.data === element.data));
			});
			details.order.forEach((element) => {
				let orig       = settings.aoColumns.find(
					x => x.idx === element.column);
				element.column = orig.index;
			});
			details.columns = original;
		});

valeriy-efimov avatar Aug 18 '22 08:08 valeriy-efimov

Yeah that does seem a crutch, but looking at that - can we even be aware on the server end of what we would need to do?

curry684 avatar Aug 18 '22 11:08 curry684

I'm flagging it as an enhancement because I do not consider optional plugins something we must properly support.

curry684 avatar Aug 18 '22 11:08 curry684

Stale issue message

github-actions[bot] avatar Nov 18 '22 22:11 github-actions[bot]