omines / datatables-bundle

DataTables bundle for Symfony
https://omines.github.io/datatables-bundle/
MIT License
251 stars 113 forks source link

ColReorder plugin dosn't work corrent #264

Closed valeriy-efimov closed 1 year ago

valeriy-efimov commented 2 years ago

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.

curry684 commented 1 year ago

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?

valeriy-efimov commented 1 year ago

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;
        });
curry684 commented 1 year ago

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 commented 1 year ago

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

github-actions[bot] commented 1 year ago

Stale issue message