Index.cshtml
@{
var ChildGrid = new Syncfusion.EJ2.Grids.Grid()
{
QueryString = "EmployeeID",
Load = "load",
Columns = new List<Syncfusion.EJ2.Grids.GridColumn> {
new Syncfusion.EJ2.Grids.GridColumn(){ Field="OrderID", HeaderText="Order ID", Width="120" },
new Syncfusion.EJ2.Grids.GridColumn(){ Field="Freight", HeaderText="Freight", Width="120", Format="C2", TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right },
new Syncfusion.EJ2.Grids.GridColumn(){ Field="ShipName", HeaderText="Ship Name", Width="150" },
new Syncfusion.EJ2.Grids.GridColumn(){ Field="ShipCity", HeaderText="Ship City", Width="120" },
},
};
}
<div class="control-section">
<ejs-grid id="HierarchyPrint" dataSource="ViewBag.DataSource2" childGrid="ChildGrid">
<e-grid-columns>
<e-grid-column field="EmployeeID" headerText="Employee ID" textAlign="Right" width="125"></e-grid-column>
<e-grid-column field="ShipName" headerText="Ship Name" width="120"></e-grid-column>
</e-grid-columns>
</ejs-grid>
</div>
<script>
function load(args) {
console.log(this.parentDetails.parentKeyField);
console.log(this.parentDetails.parentKeyFieldValue);
var ajax = new ej.base.Ajax({
type: "POST",
url: '/Home/UpdateUploadGrid',
contentType: "application/json; charset=utf-8",
data: JSON.stringify([{ EmployeeID: this.parentDetails.parentKeyFieldValue }]) // send the queryString value to the server
});
ajax.send().then(function (result) {
var data = JSON.parse(result);
console.log(this);
// bind the result (array of Object) data to the child-Grid
this.dataSource = data;
console.log(data);
}.bind(this));
}
</script>
|
[HttpPost]
public IActionResult UpdateUploadGrid([FromBody] List<extradata> data) // use the correct data type to deserialize the data
{
// filter the data based on queryString value
List<BigData> tlistFiltered = BigData.GetAllRecords().Where(item => item.EmployeeID == data[0].EmployeeID).ToList();
return Json(tlistFiltered);
}
public class extradata
{
public int EmployeeID { get; set; }
}
|
function dataBound_childGrid(args) {
if (this.element.querySelector(".e-gridcontent .e-emptyrow") && this.dataSource.length == 0) {
// change the innerText of empty row using .e-emptyrow class
this.element.querySelector(".e-gridcontent .e-emptyrow").firstElementChild.innerText = "Loading...";
}
}
|
@{
var ChildGrid = new Syncfusion.EJ2.Grids.Grid()
{
QueryString = "EmployeeID",
Load = "load_childGrid",
Created= "created_childGrid",
DataBound = "dataBound_childGrid",
------
};
}
-------
function created_childGrid(args) {
this.element.querySelector('.e-gridheader').style.display = 'none';
}
function dataBound_childGrid(args) {
this.element.querySelector('.e-gridheader').style.display = 'none';
}
|