Using SortableRows and know when rows have been mo

2020-03-04 11:59发布

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

标签: jqgrid
3条回答
小情绪 Triste *
2楼-- · 2020-03-04 12:49
jQuery('#'+grid_id).jqGrid('sortableRows', {
                    update: function (event, ui) {
                        var newOrder = $('#'+grid_id).jqGrid("getDataIDs");
                        //do whatever you want with new roworder
                        //please keep in mind this will give only page visible rows
                    }
                });
查看更多
做个烂人
3楼-- · 2020-03-04 12:55

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.

查看更多
家丑人穷心不美
4楼-- · 2020-03-04 12:55

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.

查看更多
登录 后发表回答