Dynamically enable/disable rowReordering() plugin
Dynamically enable/disable rowReordering() plugin
Hello,
I decided to try out the rowreordering plugin as seen here: http://datatables.net/forums/discussion/8725/row-reordering-plugin-with-dragndrop-capabilities-is-released/p1
Allen commented that it would be nice with an adaption so that sorting could still work, optionally. I'm a jquery nub, here is my initial attempt.
[code]
//declare the table WITHOUT reordering
var oTable = $('#example').dataTable();
// Add a jquery click or whatever conditional to add the plugin.
$('#enableReorder').click( function () {
oTable.rowReordering( { sURL:"UpdateRowOrder.php" });
});
[/code]
So far that all works fine, its disabled to begin with, it can be enabled on click.
My problem is how to REMOVE this once its been added. If it was just a setting like oSetting, i know i could change the setting then fnDraw. I thought id try fnDestroy, but even after destroying the table and rebuilding, i lose all my formatting but it keeps the plugin. Consider the following proposal i had hoped would work.
[code]
$('#buttonReorderCategory').toggle(function()
{
oTable.rowReordering( {
sURL:"UpdateRowOrder.php"
})
}, function() {
oTable.fnDestroy();
oTable.fnDraw();
});
[/code]
Firstly, using destroy is probably stupid because i have a bunch of formatting some through callbacks that i lose when i destroy and redraw, so id ideally like to keep those. But even when i destroy, it still keeps the damned .rowReordering() additional to datatables.
So anyway, if anybody has a pointer id really appreciate it. I've just about finished a full fledged crud (adapted on the server side examples), using mongodb so perhaps i can post my solution once im done for people who want inline editing with jeditables, serverside reordering using mongo and other things.
Finally, shortly before writing this, it occurred to me that from the fact that rowReordering is little known, yet plugins like datatables.jeditable is widely known, perhaps I should look and see if anybody has a solution on how to disable this instead.
Problem is, jeditables is so well written that despite it's popularity, nobody has wanted to disable this plugin dynamically on the fly so i cant see a similar method to adopt for this. That being said, if you've heard of a way to do it for .jeditables(), let me know because it may work for this...
Cheers.
I decided to try out the rowreordering plugin as seen here: http://datatables.net/forums/discussion/8725/row-reordering-plugin-with-dragndrop-capabilities-is-released/p1
Allen commented that it would be nice with an adaption so that sorting could still work, optionally. I'm a jquery nub, here is my initial attempt.
[code]
//declare the table WITHOUT reordering
var oTable = $('#example').dataTable();
// Add a jquery click or whatever conditional to add the plugin.
$('#enableReorder').click( function () {
oTable.rowReordering( { sURL:"UpdateRowOrder.php" });
});
[/code]
So far that all works fine, its disabled to begin with, it can be enabled on click.
My problem is how to REMOVE this once its been added. If it was just a setting like oSetting, i know i could change the setting then fnDraw. I thought id try fnDestroy, but even after destroying the table and rebuilding, i lose all my formatting but it keeps the plugin. Consider the following proposal i had hoped would work.
[code]
$('#buttonReorderCategory').toggle(function()
{
oTable.rowReordering( {
sURL:"UpdateRowOrder.php"
})
}, function() {
oTable.fnDestroy();
oTable.fnDraw();
});
[/code]
Firstly, using destroy is probably stupid because i have a bunch of formatting some through callbacks that i lose when i destroy and redraw, so id ideally like to keep those. But even when i destroy, it still keeps the damned .rowReordering() additional to datatables.
So anyway, if anybody has a pointer id really appreciate it. I've just about finished a full fledged crud (adapted on the server side examples), using mongodb so perhaps i can post my solution once im done for people who want inline editing with jeditables, serverside reordering using mongo and other things.
Finally, shortly before writing this, it occurred to me that from the fact that rowReordering is little known, yet plugins like datatables.jeditable is widely known, perhaps I should look and see if anybody has a solution on how to disable this instead.
Problem is, jeditables is so well written that despite it's popularity, nobody has wanted to disable this plugin dynamically on the fly so i cant see a similar method to adopt for this. That being said, if you've heard of a way to do it for .jeditables(), let me know because it may work for this...
Cheers.
This discussion has been closed.
Replies
Hi!
I'm looking for the exact same solution.
Did you find a solution for this?
$( ".ui-sortable" ).sortable("disable");
Not working disable and/or enable.