BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
My goal is to have a hierarchical grid where the user can edit certain cells of the grandchild grid by clicking or double clicking in a cell that has been declared editable. I assume I have a syntax error; my code runs, but I am unable to edit any of the cells. Please can you show me the correct syntax to make specific cells in the grandchild grid editable (without using a toolbar button?) An excerpt of my code:
@using Syncfusion.EJ2
@{
ViewBag.Title = "DataGridFeatures";
}
<h2>DataGridFeatures</h2>
<br />
<br />
<div id="ControlRegion">
@{
var grandChildColumns = new List<Syncfusion.EJ2.Grids.GridColumn>();
grandChildColumns.Add(new Syncfusion.EJ2.Grids.GridColumn() { Field = "title", HeaderText = "", Width = "130" });
grandChildColumns.Add(new Syncfusion.EJ2.Grids.GridColumn() { Field = "notes", HeaderText = "Notes", Width = "170" });
for (int i = 2; i < ViewBag.numCols; i++)
{
grandChildColumns.Add(new Syncfusion.EJ2.Grids.GridColumn()
{
Field = $"cellValues.{i - 2}",
HeaderText = ViewBag.headerCol[i],
Width = "100",
EditType = "numericedit",
Edit = new
{
@params = new Syncfusion.EJ2.Inputs.NumericTextBox()
{
ValidateDecimalOnType = true,
Decimals = 0,
Format = "N"
}
}
});
}
var grandChildGrid = new Syncfusion.EJ2.Grids.Grid()
{
DataSource = (IEnumerable<object>)ViewBag.datarows,
QueryString = "itemId",
Columns = grandChildColumns,
QueryCellInfo = "onGrandChildGridQueryCellInfo",
ExcelQueryCellInfo = "exportQueryCellInfo",
FrozenColumns = 1,
DataBound = "dbb",
};
var childGrid = new Syncfusion.EJ2.Grids.Grid()
{
DataSource = (IEnumerable<object>)ViewBag.dataitems,
QueryString = "locationId",
Columns = new List<Syncfusion.EJ2.Grids.GridColumn> {
new Syncfusion.EJ2.Grids.GridColumn(){ Field="itemId", HeaderText="ItemId", Width="120" },
new Syncfusion.EJ2.Grids.GridColumn(){ Field="description", HeaderText="Description", Width="120" },
new Syncfusion.EJ2.Grids.GridColumn(){ Field="group", HeaderText="Group", Width="120" },
new Syncfusion.EJ2.Grids.GridColumn(){ Field="quantity", HeaderText="Quantity", Width="120" },
},
ChildGrid = grandChildGrid,
DataBound = "dbb",
};
}
@Html.EJS().Grid("Locations").DataSource((IEnumerable<object>)ViewBag.datasource).Columns(col =>
{
col.Field("locationId").HeaderText("LocationId").Width("125").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("locationName").HeaderText("LocationName").Width("225").Add();
}).AllowSorting().Toolbar(new List<string>() { "PdfExport", "ExcelExport", "ExpandAll" }).ToolbarClick("toolbarClick").ChildGrid(childGrid).AllowPdfExport().AllowExcelExport().DataBound("dbb").ExcelQueryCellInfo("exportQueryCellInfo").Render()
</div>
Hi Electa,
Greetings from Syncfusion support.
On inspecting the code example provided, we could see that you have not enabled editing to any of the grids in your code. Please refer the below documentation for more details on performing crud operations.
Documentaiton:
https://ej2.syncfusion.com/aspnetmvc/documentation/grid/editing/in-line-editing
Regards,
Joseph I.