How to use server side processing with colReorder and rowCallback html changing?

How to use server side processing with colReorder and rowCallback html changing?

AlexBuwAlexBuw Posts: 2Questions: 1Answers: 0

When I reorder columns, they reset to state before rowCallback action.

To see example go to Server-side processing example page
Enter this script in command line:

$('#example').dataTable({
  processing: true,
  serverSide: true,
  rowCallback: function(row, data, index) {
    $('td:eq(3)', row).html( '<b>Test</b>' );
  },
  ajax: "/examples/server_side/scripts/objects.php",
  columns: [
    { data: "first_name" },
    { data: "last_name" },
    { data: "position" },
    { data: "office" },
    { data: "start_date" },
    { data: "salary" }
  ],
  colReorder: true,
  destroy: true,
});

And try to reorder the columns. The new html will reset.

p.s. When I do $('td:eq(3)', row).replaceWith($('td:eq(3)', row).clone().html( '<b>Test</b>' )); it works, but I have another trouble with show/hide columns: jquery.dataTables.js:8478 Uncaught NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
At line:

// insertBefore can act like appendChild if 2nd arg is null
tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );

So I think what it is wrong decision.

Answers

  • allanallan Posts: 61,864Questions: 1Answers: 10,136 Site admin

    Thanks for the PR. I'm not entirely sure that this is the full answer to the problem - with that change the $.fn.dataTable.Api( oSettings ).rows().invalidate(); line will never be executed since invalidateRows is never actually passed in as true.

    I'll try to look into the issue a bit further and post back when I get a chance to do so.

    Allan

This discussion has been closed.