Your search did not match any results.
Data Grid

Drag & Drop Between Two Grids

This functionality requires that data objects have a data field that identifies which grid they belong to. In this demo, this data field is Status.

To allow users to move rows between grids, follow these steps:

  1. Bind the grids to the same store
    The store should be able to update data. In this demo, the store is created using the createStore method (part of the DevExtreme.AspNet.Data extension). The specified updateUrl enables the store to update data.

  2. Specify grid identifiers
    Save them in the option. The grids below have identifiers 1 and 2.

  3. Filter the grids to display different record sets
    Use the identifiers in the filterValue option to filter the grids. The grids below display only the records whose Status field equals the grid's identifier.

  4. Join the grids into one drag and drop group
    Set the option to the same value for all grids to allow moving rows between them.

  5. Update the data field that specifies where the row belongs
    Implement the rowDragging.onAdd function. To access the target grid's identifier, use the toData function parameter. Call the store's update method to send this identifier to the server and push the same changes to the store on the client. The grids are refreshed automatically if you enable reshapeOnPush in the dataSource.

Copy to CodeSandBox
<template> <div class="tables"> <Grid :tasks-store="tasksStore" :status="1" class="column" /> <Grid :tasks-store="tasksStore" :status="2" class="column" /> </div> </template> <script> import * as AspNetData from 'devextreme-aspnet-data-nojquery'; import Grid from './Grid.vue'; const url = ''; const tasksStore = AspNetData.createStore({ key: 'ID', loadUrl: `${url }/Tasks`, updateUrl: `${url }/UpdateTask`, onBeforeSend: function(method, ajaxOptions) { ajaxOptions.xhrFields = { withCredentials: true }; } }); export default { components: { Grid }, data() { return { tasksStore }; } }; </script> <style scoped> .tables { display: flex; } .column:first-child { width: 50%; padding-right: 15px; } .column:last-child { width: 50%; padding-left: 15px; } </style>
<template> <DxDataGrid :data-source="dataSource" :height="440" :show-borders="true" :filter-value="filterExpr" > <DxRowDragging :data="status" :on-add="onAdd" group="tasksGroup" /> <DxScrolling mode="virtual"/> <DxColumn data-field="Subject" data-type="string" /> <DxColumn :width="80" data-field="Priority" data-type="number" > <DxLookup :data-source="priorities" value-expr="id" display-expr="text" /> </DxColumn> <DxColumn :visible="false" data-field="Status" data-type="number" /> </DxDataGrid> </template> <script> import { DxDataGrid, DxColumn, DxRowDragging, DxScrolling, DxLookup } from 'devextreme-vue/data-grid'; const priorities = [{ id: 1, text: 'Low' }, { id: 2, text: 'Normal' }, { id: 3, text: 'High' }, { id: 4, text: 'Urgent' }]; export default { components: { DxDataGrid, DxColumn, DxRowDragging, DxScrolling, DxLookup }, props: { tasksStore: { type: Object, default: ()=>({}) }, status: { type: Number, default: 0 } }, data() { return { dataSource: { store: this.tasksStore, reshapeOnPush: true }, priorities, filterExpr: ['Status', '=', this.status], }; }, methods: { onAdd(e) { var key = e.itemData.ID, values = { Status: e.toData }; this.tasksStore.update(key, values).then(() => { this.tasksStore.push([{ type: 'update', key: key, data: values }]); }); } } }; </script>
import Vue from 'vue'; import App from './App.vue'; new Vue({ el: '#app', components: { App }, template: '<App/>' });
<!DOCTYPE html> <html> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <link rel="stylesheet" type="text/css" href="" /> <link rel="stylesheet" type="text/css" href="" /> <script src=""></script> <script src=""></script> <script type="text/javascript" src="config.js"></script> <script type="text/javascript"> System.import('./index.js'); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"> </div> </div> </body> </html>
System.config({ transpiler: 'plugin-babel', meta: { '*.vue': { loader: 'vue-loader' }, 'devextreme-aspnet-data-nojquery': { "esModule": true }, }, paths: { 'npm:': '' }, map: { 'vue': 'npm:vue@2.6.3/dist/vue.esm.browser.js', 'vue-loader': 'npm:dx-systemjs-vue-browser@latest/index.js', 'devextreme-aspnet-data-nojquery': 'npm:devextreme-aspnet-data-nojquery@2.6.1', 'devextreme': 'npm:devextreme@20.1', 'devextreme-vue': 'npm:devextreme-vue@20.1', 'jszip': 'npm:jszip@3.1.3/dist/jszip.min.js', 'quill': 'npm:quill@1.3.7/dist/quill.js', 'devexpress-diagram': 'npm:devexpress-diagram@1.0.17', 'devexpress-gantt': 'npm:devexpress-gantt@1.0.10', 'plugin-babel': 'npm:systemjs-plugin-babel@0/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel@0/systemjs-babel-browser.js' }, packages: { 'devextreme-vue': { main: 'index.js' }, 'devextreme': { defaultExtension: 'js' }, 'devextreme/events/utils': { main: 'index' }, 'devextreme/events': { main: 'index' }, }, babelOptions: { sourceMaps: false, stage0: true } });