views:

210

answers:

2

I want to take advantage of the sortableRows property of the jqGrid. How do I detect when a row has been moved. I have studied the documentation and looked for examples but haven't found much. I do believe it is something like

jQuery("#grid").sortableRows({connectWith:'#gird',
                              ondrop: function(){ alert("row moved") }});

but that does not work. I can move the rows, but don't seemed to have trapped the event. Is there something wrong with my syntax or my approach in general.

Basically, I need to know that the rows have been rearranged so I can be sure they get saved with their new order.

Thanks

+2  A: 

Attach the sortstop event handler to your grid:

jQuery("#grid").bind('sortstop', function(event, ui) { alert("row moved") });

I did a quick test and that worked for me.

Mark
A: 

jqGrid uses the ui-sortable plugin to sort rows: http://jqueryui.com/demos/sortable/. In

jQuery("#grid").sortableRows( options )

"options" is the passed to the sortable plugin.

options = { update : function(e,ui){} }

is what you want.

Kevin