<template>
<div id="app">
<ejs-grid id='Grid' :dataSource="data" :allowPaging="true" :allowRowDragAndDrop="true" :rowDrop="rowDrop" :rowDropSettings="srcDropOptions" width="49%">
</ejs-grid>
<ejs-treeview id='treeview' :fields='fields'></ejs-treeview>
</div>
</template>
<script>
import Vue from "vue";
import { GridPlugin, Toolbar, Page, Edit, RowDD } from "@syncfusion/ej2-vue-grids";
import { data } from './datasource.js';
import { TreeViewPlugin } from "@syncfusion/ej2-vue-navigations";
import { DataManager, ODataAdaptor, Query } from "@syncfusion/ej2-data";
Vue.use(GridPlugin);
Vue.use(TreeViewPlugin);
export default {
data() {
return {
};
},
provide: {
grid: [Page, RowDD]
},
methods: {
rowDrop: function(args){
var currLi = args.target.closest('li');
var gridData = args.data;
if(currLi !=null && currLi.closest('.e-control').classList.contains('e-treeview'))
{
if(gridData != null){
var grid = (document.getElementById('Grid')).ej2_instances[0];
var tree = (document.getElementById('treeview')).ej2_instances[0];
let SERVICE_URI =
var val = new DataManager({
url: SERVICE_URI,
adaptor: new ODataAdaptor()
}).executeQuery(new Query().where("OrderID", "equal", gridData[0].OrderID)).then(function(e){
for(var i = 0, len = e.result.length; i < len; i++){
var obj = [{ nodeId:e.result[i].OrderID,nodeText:e.result[i].CustomerID }];
tree.addNodes(obj,currLi);
}
});
args.cancel=true;
}
}
}
}
}
</script> |
rowDrop: function(args){
var currLi = args.target.closest('li');
var gridData = args.data;
if(currLi != null && currLi.closest('.e-control').classList.contains('e-treeview'))
{
if(gridData != null){
var grid = (document.getElementById('Grid')).ej2_instances[0];
var tree = (document.getElementById('treeview')).ej2_instances[0];
// Get the treeitem where the griditem is dropped on
// Then sent a ajax request to /endpoint/gridData[0].OrderId/moveTo/treeItem.nodeId
// Reload grid
}
}
}
Regards
rowDrop: function(args){
var currLi = args.target.closest('li');
var gridData = args.data;
if(currLi !=null && currLi.closest('.e-control').classList.contains('e-treeview'))
{
if(gridData != null){
var grid = (document.getElementById('Grid')).ej2_instances[0];
var tree = (document.getElementById('treeview')).ej2_instances[0];
let treeItem = [{ nodeId: args.data[0].OrderID, nodeText: args.data[0].CustomerID, hasChildren: true }];
tree.addNodes(treeItem);
args.cancel=true;
}
}
} |
rowDrop: function(args){
var currLi = args.target.closest('li');
var gridData = args.data;
if(currLi != null && currLi.closest('.e-control').classList.contains('e-treeview'))
{
if(gridData != null){
var grid = (document.getElementById('Grid')).ej2_instances[0];
var tree = (document.getElementById('treeview')).ej2_instances[0];
// Get the fileId and the folderId
var fileId = gridData[0].OrderID;
var folderId = currLi.dataset.uid;
console.log(fileId, folderId);
}
}
}
rowDrop: function(args) {
var currLi = args.target.closest('li');
var gridData = args.data;
if (currLi != null && currLi.closest('.e-control').classList.contains('e-treeview')) {
if (gridData != null) {
var grid = (document.getElementById('Grid')).ej2_instances[0];
var tree = (document.getElementById('treeview')).ej2_instances[0];
var fileId = gridData[0].OrderID;
var folderId = currLi.getAttribute("data-uid");
console.log(fileId, folderId);
args.cancel = true;
}
}
} |