I have to show a nested grid. Where for few elements child data is there and for few it is not available.
Requirement :
<ejs-grid #grid [dataSource]='employeeData' (detailDataBound)='detailDataBound($event)' id='Grid'>
<ng-template #detailTemplate let-data>
<div class='custom-grid'></div>
</ng-template>
<e-columns>
. . . . . . . . . . .
</e-columns>
</ejs-grid>
|
detailDataBound(e) {
this.predicate = new Predicate("EmployeeID", "equal", e.data["EmployeeID"]);
this.data = new DataManager({
url:
adaptor: new ODataV4Adaptor()
})
.executeQuery(new Query().where(this.predicate))
.then(e => {
// you can add you data as per your needs
this.gridObj.dataSource = (e as any).result;
});
let detail = new Grid({
columns: [
{ field: "OrderID", headerText: "Order ID", width: 110 },
{ field: "CustomerID", headerText: "Customer Name", width: 140 },
{ field: "ShipCountry", headerText: "Ship Country", width: 150 }
]
});
detail.appendTo(<HTMLElement>e.detailElement.querySelector(".custom-grid"));
this.gridObj = e.detailElement.getElementsByClassName("e-grid" )[0].ej2_instances[0];
}
|
.e-row[aria-selected="true"] .e-customizedExpandcell {
background-color: #e0e0e0;
}
.e-grid.e-gridhover tr[role='row']:hover {
background-color: #eee;
}
|
rowDataBound(e: any) {
var argument: any = e;
this.initPredit = new Predicate("EmployeeID", "equal", e.data["EmployeeID"]);
this.checkdata = new DataManager({
url:
adaptor: new ODataV4Adaptor()
}).executeQuery(new Query().where(this.initPredit)).then((e) => {
if((e as any).result.length === 0) { //if the result length is zero, we have added the class to the
console.log(argument); td for hiding the expand icon
argument.row.querySelector('td').innerHTML= '';
argument.row.querySelector('td').className = 'e-customizedExpandcell';
}
});
}
|
Hello Rajapandi,
I saw your solution but you have used data manager with an external link. Can you please suggest with the data coming from backend api as i have used in the attached query?
This way won't work for me so please suggest with the data structure used in the query code.
Regards
Neha
Hello Rajapandi,
Good day! I expect a response with the way it is shared in the query. Changing the entire coding for data binding won't help.
Please provide the html way for the solution as I have already mentioned the data structure in the sample code.
NOTE : If you notice there are certain condition based on which I need to add icons.
Regards
Neha
Hello Rajapandi,
Good day!
Can you please schedule a call ASAP. for this. As I can see there is lack of information and it is taking too long to respond with reply. It will be really helpful if you can find some time on MONDAY EARLY MORNING to have this call and short this out.
Regards
Neha
Requirement :
Below data is coming from API.
Grid with col - deviceId, Area, Battery, Country
Child grid with col - alertType, severity, threshold (if severity is 'High' add ! symbol from assest folder else no symbol)
Sample data :
Hello Rajapandi,
Can you please schedule a call now? It is urgent?
Regards
Neha
Index.html
<style>
.e-row[aria-selected="true"] .e-customizedExpandcell {
background-color: #e0e0e0;
}
.e-grid.e-gridhover tr[role='row']:hover {
background-color: #eee;
}
</style> |
App.component.ts
rowDataBound(args) {
if(args.data.deviceAlertRules.length == 0) {
//here hide which parent row has no child records
args.row.querySelector('td').innerHTML=' ';
args.row.querySelector('td').className = 'e-customizedExpandcell';
}
}
|
Thank you it worked.
Regards
Neha