Event for column Dropped After Reordering?
Event for column Dropped After Reordering?
Jason B Jones
Posts: 13Questions: 3Answers: 1
in ColReorder
I need a function to run exactly one time for every column reordering, only after it has been dropped. Both the column-reorder and columns-reordered events seem to fire while dragging. Looks like this was previously achieved with the depreciated realtime option. Was this replaced with another solution to this problem?
Alternatively, I could use the details.drop flag in conjunction with those events but I have not observed the value of this to ever be defined in my testing
Answers
sometimes a "setTimeout" helps in these situations. I've had to deal with too many server calls on certain events. I resolved this by setting and checking global variables before and after the server calls.
One option is to create your own event but this requires modifying colreorder.js. Look for the function
ColReorder.prototype._mouseUp
and add these lines:Full example:
Then add this event handler to your page:
Here is a test case:
https://live.datatables.net/zigoviyi/1/edit
At the top of the JavaScript tab is colreorder.js with the above modification. It has the
column-reorder
andcolumns-reordered
events plus the newly createdcolumns-reordered-dropped
event. It does seem useful to have an event like this.Maybe @allan can add this or possibly you can create a PR to make the changes you are interested in.
Kevin