Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid disable sortablerows

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?

like image 409
gurun8 Avatar asked Apr 30 '10 19:04

gurun8


1 Answers

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.

like image 83
gurun8 Avatar answered Sep 28 '22 13:09

gurun8