|
[fetchdata.component.html]
<ejs-grid #grid [dataSource]='parentData' [childGrid]='childGrid' [editSettings]='editSettings' [toolbar]='toolbar' [allowPaging]='true' [filterSettings]='filterOptions'>
<e-columns>
<e-column field='ID' isPrimaryKey=true headerText='ID' textAlign='Right' width=120></e-column>
<e-column field='CustomerID' headerText='CustomerID' width=150></e-column>
<e-column field='ShipCountry' headerText='ShipCountry' width=150></e-column>
</e-columns>
</ejs-grid>
[fetchdata.component.ts]
export class FetchDataComponent {
. . .
public childGrid: any;
public ChildData: DataManager | Object[];
. . .
ngOnInit(): void {
. . .
this.parentData = new DataManager({
url: 'Home/UrlDatasource',
adaptor: new UrlAdaptor
});
this.ChildData = new DataManager({
url: 'Home/ChildUrl',
adaptor: new UrlAdaptor
});
this.childGrid = {
dataSource: this.ChildData,
allowPaging: true,
pageSettings: {pageSize:5},
queryString: 'ID',
columns: [
{ field: 'ID', headerText: 'ID', textAlign: 'Right', width: 120 },
{ field: 'Permissions', headerText: 'Permissions', width: 150 }
]
};
}
[Home controller.cs]
public IActionResult UrlDatasource([FromBody]DataManagerRequest dm)
{
var order = OrdersDetails.GetAllRecords();
var Data = order.ToList();
int count = order.Count();
return dm.RequiresCounts ? Json(new { result = Data.Skip(dm.Skip).Take(dm.Take), count = count }) : Json(Data);
}
public IActionResult ChildUrl([FromBody]DataManagerRequest dm)
{
var order = ChildDetails.GetAllRecords();
var Data = order.ToList();
if (dm.Where != null)
{
Data = ChildDetails.GetAllRecords().Where(or => or.ID.ToString() == dm.Where[0].value.ToString()).ToList();
}
int count = Data.Count();
return Json(new { result = Data.Skip(dm.Skip).Take(dm.Take), count = count });
}
|