I'm trying to disable sortablerows functionality from a grid. I'd like to have the ability to toggle on/off the sortablerows functionality. Enabling the feature is pretty straightforward:
jQuery("#list").jqGrid('sortableRows', {
update: function(event, ui) { updateOrder() }
});
But disabling the feature has proven to be a little bit harder. I've consulted the UI Integrations where sortableRows
is documented in the jqGrid Wiki:
www.trirand.com/jqgridwiki/doku.php?id=wiki:jquery_ui_methods
And found that "The method is fully compatible with jQuery UI sortable widget." So I ventured off to the jQuery UI sortable documentation and found this:
http://jqueryui.com/demos/sortable/
jQuery("#list").jqGrid('sortableRows', {disabled: true});
The code above simply disables the rows. So I moved onto the destroy
method:
jQuery("#list").jqGrid('sortableRows', {destroy: true});
but that doesn't do anything. Based upon the documentation the destroy
method seems to be exactly what I need, so maybe my syntax is wrong but I can't seem to get it to work.
Does anyone have experience with this same issue?
It took awhile for me to figure this one out but I got it and it's pretty simple. This is all you need to do:
$("#list tbody").sortable("destroy");
My initial instincts to turn to jQuery UI Sortable documentation were right on. My syntax wasn't. I dug through the jqgrid JS file and found this:
a("tbody:first", i).sortable(b)
Which then pointed me in the right direction. It appears that the tbody is the hinge pin to the entire mess.
Not that anyone cares but I thought I should share in case someone else has a similar issue and my solution isn't a 100% fit for them.
Anywho, thanks for the help y'all. Mission accomplished.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With