Drill through grid cell edit type in Vue Pivotview component
11 Jun 20247 minutes to read
Using the drillThrough
event in the pivot table, you can define the edit type of a particular column in the grid present inside the drill-through dialog. To do so, check the column name in the drillThrough
event and then specify the edit type of that column using the gridColumns.editType
event argument.
The
gridColumns.editType
property must be set based on the column’s data type. For example, the string data type will not be applicable for the numeric text box edit type.
-
NumericTextBox
control for integer, double, and decimal data types. -
TextBox
control for string data type. -
DropDownList
control to show all unique values related to that field. -
CheckBox
control for boolean data type. -
DatePicker
control for date data type. -
DateTimePicker
control for date time data type.
In the below example, the data type of the Country
column is set to DropDownList
.
<template>
<div id="app">
<ejs-pivotview :dataSourceSettings="dataSourceSettings" :height="height" :editSettings="editSettings" :drillThrough="drillThrough"> </ejs-pivotview>
</div>
</template>
<script setup>
import { provide } from "vue";
import { PivotViewComponent as EjsPivotview, DrillThrough } from "@syncfusion/ej2-vue-pivotview";
import { pivotData } from './pivotData.js';
const dataSourceSettings= {
dataSource: pivotData,
expandAll: false,
drilledMembers: [{ name: 'Country', items: ['France'] }],
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }],
rows: [{ name: 'Country' }, { name: 'Products' }],
formatSettings: [{ name: 'Amount', format: 'C0' }],
filters: []
}
const height= 350
const editSettings= { allowAdding: true, allowDeleting: true, allowEditing: true, mode: 'Normal' }
provide('pivotview', [DrillThrough]);
const drillThrough=(args)=> {
for (var i = 0; i < args.gridColumns.length; i++) {
if (args.gridColumns[i].field === 'Country') {
args.gridColumns[i].editType = 'dropdownedit';
//args.gridColumns[i].editType = 'numericedit';
//args.gridColumns[i].editType = 'textedit';
//args.gridColumns[i].editType = 'booleanedit';
//args.gridColumns[i].editType = 'datepickeredit';
//args.gridColumns[i].editType = 'datetimepickeredit';
}
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-pivotview/styles/material.css";
</style>
<template>
<div id="app">
<ejs-pivotview :dataSourceSettings="dataSourceSettings" :height="height" :editSettings="editSettings" :drillThrough="drillThrough">
</ejs-pivotview>
</div>
</template>
<script>
import { PivotViewComponent, DrillThrough } from "@syncfusion/ej2-vue-pivotview";
import { pivotData } from './pivotData.js';
export default {
name: "App",
components: {
"ejs-pivotview": PivotViewComponent
},
data() {
return {
dataSourceSettings: {
dataSource: pivotData,
expandAll: false,
drilledMembers: [{ name: 'Country', items: ['France'] }],
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }],
rows: [{ name: 'Country' }, { name: 'Products' }],
formatSettings: [{ name: 'Amount', format: 'C0' }],
filters: []
},
height: 350,
editSettings: { allowAdding: true, allowDeleting: true, allowEditing: true, mode: 'Normal' }
}
},
provide: {
pivotview: [DrillThrough]
},
methods: {
drillThrough: function (args) {
for (var i = 0; i < args.gridColumns.length; i++) {
if (args.gridColumns[i].field === 'Country') {
args.gridColumns[i].editType = 'dropdownedit';
//args.gridColumns[i].editType = 'numericedit';
//args.gridColumns[i].editType = 'textedit';
//args.gridColumns[i].editType = 'booleanedit';
//args.gridColumns[i].editType = 'datepickeredit';
//args.gridColumns[i].editType = 'datetimepickeredit';
}
}
}
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-pivotview/styles/material.css";
</style>