Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
150459 | Jan 7,2020 10:28 PM UTC | Jan 9,2020 06:42 PM UTC | Vue | 1 |
![]() |
Tags: Data Grid |
App.vue
<template>
<div class="col-lg-12 control-section">
<div>
<ejs-grid
ref="grid"
id="gridcomp"
. . .
:contextMenuItems="contextMenuItems"
:contextMenuOpen="contextMenuOpen"
:editSettings="editing"
>
. . .
</ejs-grid>
</div>
</div>
</template>
<script>
import Vue from "vue";
import { GridPlugin, ContextMenu } from "@syncfusion/ej2-vue-grids";
import { data } from "./data";
Vue.use(GridPlugin);
export default Vue.extend({
data: () => {
return {
data: data,
contextMenuItems: [
{
text: "Custom1",
target: ".e-content",
id: "custom"
},
{
text: "Custom2",
target: ".e-content",
id: "custom2"
}
],
editing: { allowDeleting: true, allowEditing: true }
};
},
methods: {
contextMenuOpen: function(args) {
// you can get the rowData in contexMenu open event args also
var contextMenuObj = this.$refs.grid.ej2Instances.contextMenuModule
.contextMenu; //getting the contextMenu instance
if (args.rowInfo.rowData.OrderID % 2 === 0) { //here you can apply your own conditions as per your requirement
contextMenuObj.enableItems(["Custom1"], false);
contextMenuObj.hideItems(["Custom2"]);
} else {
contextMenuObj.enableItems(["Custom1"], true);
contextMenuObj.showItems(["Custom2"]);
}
},
contextMenuClick: function(args) {
if (args.item.id === "custom") {
args.item.text = "changed";
}
}
},
provide: {
grid: [ContextMenu]
}
});
</script> |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.