Html
<div class="control-section">
<ejs-grid #grid [dataSource]='data' id='Grid'>
<ng-template #detailTemplate let-data>
// we can pass the parentRowdata along with employeeid here
<ejs-tab id="element" (created)="tabCreated(data)">
<e-tabitems>
// to change header dynamically
<e-tabitem [header]='headerText[0]'>
<ng-template #content>
<ejs-grid #tabGrid1 [id]="tab1grid(data)" (load)="gridload(data)" height='350' [allowRowDragAndDrop]='true'
[selectionSettings]='selectOptions' height='400'>
. . . </ejs-grid>
</ng-template>
</e-tabitem>
<e-tabitem [header]='headerText[1]'>
<ng-template #content>
<ejs-grid [dataSource]='dataGrid2' height='350' [allowRowDragAndDrop]='true'
[selectionSettings]='selectOptions' height='400'>
<e-columns>
. . .
</ejs-grid>
</ng-template>
</e-tabitem>
<e-tabitem [header]='headerText[2]'>
</ejs-grid>
</div>
|
TS
. . .
export class AppComponent implements OnInit {
public data: any;
@ViewChild('grid', { static: false })
public grid: GridComponent;
public headerText: Object = [{ 'text': 'Tab1' }, { 'text': 'Tab2' },{ 'text': 'Tab3' }];
public dataGrid2: Object[] = [];
public selectOptions: Object;
constructor() {
this.data = employeeData;
}
ngOnInit() {
this.dataGrid2 = orderDetails;
this.selectOptions = { type: 'Multiple' };
}
tabCreated (args) {
// dynamically updating the tab header
this.headerText[0].text = 'Tab -'+ args['EmployeeID'];
this.headerText[1].text = 'SecondTab -'+ args['EmployeeID'];
this.headerText[2].text = 'ThirdTab -'+ args['EmployeeID'];
}
tab1grid (args) {
return 'tab1Grid' + args['EmployeeID'];
}
gridload (data) {
// here you can call the service and load the data for Grid
let grid = (document.getElementById('tab1Grid'+data['EmployeeID']) as any).ej2_instances[0];
grid.dataSource = orderDatas;
grid.query = new Query().where('EmployeeID', 'equal', data['EmployeeID']);
}
}
|
<div class="control-section">
<ejs-grid #grid [dataSource]='data' [columns]="parentColumns" id='Grid'>
<ng-template #detailTemplate let-data>
</ng-template>
</ejs-grid>
</div>
|
. . .
ngOnInit() {
this.data = employeeData;
this.parentColumns= [
{ field: 'EmployeeID',visible: false, headerText: 'Employee ID', textAlign: 'Right', width: 125 },
{ field: 'FirstName', headerText: 'Name', width: 125 },
{ field: 'Title', headerText: 'Title', width: 180 },
{ field: 'City', headerText: 'City', width: 110 },
{ field: 'Country', headerText: 'Country', width: 110 }
];
. . .
}
|