|
<template>
<div>
<ejs-grid
ref="grid"
:dataSource="data"
:editSettings="editSettings"
:allowSelection="true"
:allowRowDragAndDrop="true"
:selectionSettings="selectionOptions"
height="410px"
>
<e-columns>
.. .
</e-columns>
</ejs-grid>
</template>
<script>
import Vue from "vue";
export default {
data: function () {
return {
data: data,
selectionOptions: { type: "Multiple" },
};
},
methods: {},
provide: {
grid: [RowDD, Selection],
},
};
</script>
|
|
app.component.ts
<div class="control-section">
<ejs-grid #grid [dataSource]="data" [allowRowDragAndDrop]='true' (commandClick)='commandClick($event)'>
<e-columns>
<e-column headerText="Manage Records" width="160" [commands]="commands"></e-column>
</e-columns>
</ejs-grid>
</div>
----------------------------------------------------------- app.component.ts export class AppComponent { ngOnInit(): void {
this.data = employeeData;
this.commands = [
{
title: "up",
buttonOption: { cssClass: "e-flat", iconCss: "e-icons e-up" }
},
{
title: "down",
buttonOption: { cssClass: "e-flat", iconCss: "e-icons e-down" }
}
];
}
commandClick(args) {
var oID = [];
var currentIndex = parseInt(
args.target.closest("tr").getAttribute("aria-rowindex")
); // to get the current row index
oID.push(currentIndex);
if (args.commandColumn.title == "up" && currentIndex != 0) {
this.grid.reorderRows(oID, currentIndex - 1);
}
if (args.commandColumn.title == "down") {
this.grid.reorderRows(oID, currentIndex + 1);
}
}
}
|