Drill-through grid’s cell edit type
2 Aug 20232 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 GridColumn.EditType
event argument.
NOTE
The
GridColumn.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
.
@Html.EJS().PivotView("PivotGrid").Width("100%").Height("300").DataSource(dataSource => dataSource.Data((IEnumerable<object>)ViewBag.Data).ExpandAll(false).EnableSorting(true)
.FormatSettings(formatsettings =>
{
formatsettings.Name("Amount").Format("C0").MaximumSignificantDigits(10).MinimumSignificantDigits(1).UseGrouping(true).Add();
}).Rows(rows =>
{
rows.Name("Country").Add(); rows.Name("Products").Add();
}).Columns(columns =>
{
columns.Name("Year").Caption("Production Year").Add(); columns.Name("Quarter").Add();
}).Values(values =>
{
values.Name("Sold").Caption("Units Sold").Add(); values.Name("Amount").Caption("Sold Amount").Add();
})).DrillThrough("drillThrough").EditSettings(new PivotViewCellEditSettings{AllowAdding=true;AllowDeleting=true;AllowEditing=true;AllowCommandColumns=true}).Render()
<script>
function 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>
public ActionResult Index()
{
var data = GetPivotData();
ViewBag.DataSource = data;
return View();
}