Drill through grid cell edit type in EJ2 JavaScript Pivotview control
8 Aug 20235 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.editTypeproperty 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.
-
NumericTextBoxcontrol for integer, double, and decimal data types. -
TextBoxcontrol for string data type. -
DropDownListcontrol to show all unique values related to that field. -
CheckBoxcontrol for boolean data type. -
DatePickercontrol for date data type. -
DateTimePickercontrol for date time data type.
In the below example, the data type of the Country column is set to DropDownList.
var pivotGridObj = new ej.pivotview.PivotView({
dataSourceSettings: {
dataSource: pivotData,
expandAll: false,
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }],
rows: [{ name: 'Country' }, { name: 'Products' }],
},
height: 350,
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';
}
}
},
editSettings: { allowAdding: true, allowDeleting: true, allowEditing: true, mode: 'Normal' }
});
pivotGridObj.appendTo('#PivotTable');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Pivot Grid</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript Pivot Grid Control">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-buttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-calendars/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-dropdowns/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-grids/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-charts/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-lists/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-navigations/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-popups/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-splitbuttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/31.2.12/ej2-pivotview/styles/material.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/31.2.12/dist/ej2.min.js" type="text/javascript"></script>
<script src="es5-datasource.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div>
<div id="PivotTable"></div>
</div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>