EasyUI 数据网格行拖放(Drag and Drop Rows in DataGrid)
https://www.jeasyui.net/extension/193.html
EasyUI 数据网格行拖放(Drag and Drop Rows in DataGrid)

用法
包含 'datagrid-dnd.js' 文件
- <script type="text/javascript" src="datagrid-dnd.js"></script>
启用拖拽与放置
- <table class="easyui-datagrid" title="DataGrid" style="width:700px;height:250px" data-options="
- singleSelect:true,
- data:data,
- onLoadSuccess:function(){
- $(this).datagrid('enableDnd');
- }
- ">
- <thead>
- <tr>
- <th data-options="field:'itemid',width:80">Item ID</th>
- <th data-options="field:'productid',width:100">Product</th>
- <th data-options="field:'listprice',width:80,align:'right'">List Price</th>
- <th data-options="field:'unitcost',width:80,align:'right'">Unit Cost</th>
- <th data-options="field:'attr1',width:250">Attribute</th>
- <th data-options="field:'status',width:60,align:'center'">Status</th>
- </tr>
- </thead>
- </table>
事件
该事件扩展自数据网格(datagrid),下面是为数据网格(datagrid)添加的事件。
名称 | 参数 | 描述 |
---|---|---|
onBeforeDrag | row | 当一行的拖拽开始前触发,返回 false 则取消拖拽。 |
onStartDrag | row | 当开始拖拽一行时触发。 |
onStopDrag | row | 当停止拖拽一行后触发。 |
onDragEnter | targetRow, sourceRow | 当拖拽一行进入某允许放置的目标行时触发,返回 false 则取消放置。 |
onDragOver | targetRow, sourceRow | 当拖拽一行在某允许放置的目标行上时触发,返回 false 则取消放置。 |
onDragLeave | targetRow, sourceRow | 当拖拽一行离开某允许放置的目标行时触发。 |
onBeforeDrop | targetRow,sourceRow,point | 当一行被放置前触发,返回 false 则取消放置。 targetRow:放置的目标行。 sourceRow:拖拽的源行。 point:指示放置的位置,可能的值:'top' 或 'bottom'。 |
onDrop | targetRow,sourceRow,point | 当一行被放置时触发。 targetRow:放置的目标行。 sourceRow:拖拽的源行。 point:指示放置的位置,可能的值:'top' 或 'bottom'。 |
方法
该方法扩展自数据网格(datagrid)。
名称 | 参数 | 描述 |
---|---|---|
enableDnd | index | 启用行的拖拽与放置。 'index' 参数指示要被拖拽与放置的行。 如果该参数未指定,则拖拽与放置所有行。 代码实例:
|
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了