Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery EasyUI Extension - DataGrid Row Drag and Drop

jQuery EasyUI Extension - DataGrid Row Drag and Drop (Drag and Drop Rows in DataGrid)


jQuery EasyUI Extensions jQuery EasyUI Extension


Usage

Include the 'datagrid-dnd.js' file





Enable drag and drop



    

        

            

                

                

                

                

                

                

            

        

    
Item IDProductList PriceUnit CostAttributeStatus

Events

This event extends from the datagrid; below are the events added for the datagrid.

Name Parameters Description
onBeforeDrag row Triggered before the drag of a row starts; returning false cancels the drag.
onStartDrag row Triggered when a row starts being dragged.
onStopDrag row Triggered after a row stops being dragged.
onDragEnter targetRow, sourceRow Triggered when a dragged row enters a target row where dropping is allowed; returning false cancels the drop.
onDragOver targetRow, sourceRow Triggered when a dragged row is over a target row where dropping is allowed; returning false cancels the drop.
onDragLeave targetRow, sourceRow Triggered when a dragged row leaves a target row where dropping is allowed.
onBeforeDrop targetRow,sourceRow,point Triggered before a row is dropped; returning false cancels the drop.
 targetRow:放置的目标行。       

 sourceRow:拖拽的源行。       

 point:指示放置的位置,可能的值:'top' 或 'bottom'。 |

| onDrop | targetRow,sourceRow,point | Triggered when a row is dropped.
targetRow: the target row for the drop.
sourceRow: the source row being dragged.
point: indicates the drop position; possible values: 'top' or 'bottom'. |

Method

This method extends from the datagrid.

Name Parameters Description
enableDnd index Enable row drag and drop.
 'index' 参数指示要被拖拽与放置的行。       

 如果该参数未指定,则拖拽与放置所有行。     

代码实例:


$('#dg').datagrid('enableDnd', 1);    // enable dragging on second row $('#dg').datagrid('enableDnd');    // enable dragging all rows |

Download jQuery EasyUI Examples

jquery-easyui-datagrid-dnd.zip


jQuery EasyUI Extensions jQuery EasyUI Extensions