In angular -7
@ViewChild('template2')
public ddTemplate: any; // using this code in angular 9 returns undefined value so please use the below code
to get the ViewChild
above angular - 8
@ViewChild('template2', { static: true })
public ddTemplate: any;
|
App.component.html
<ejs-grid #grid [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar'>
<e-columns>
------
</e-columns>
</ejs-grid>
<ng-template #template2 let-data>
<ejs-dropdownlist id='ddlelement' #samples [dataSource]='dropdowndata' [placeholder]='placeholder' (change)="change($event)"></ejs-dropdownlist>
</ng-template>
App.component.ts
export class AppComponent {
---------
@ViewChild('grid', { static: true }) public grid: GridComponent;
//get the viewChild element
@ViewChild('template2', { static: true })
public ddTemplate: any;
public ngOnInit(): void {
// display the viewChild element in console
console.log(this.ddTemplate);
this.data = hierarchyOrderdata;
this.editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Dialog' };
this.toolbar = ['Add', 'Edit', 'Delete','Search' , {template: this.ddTemplate}];
this.orderidrules = { required: true, number: true };
this.customeridrules = { required: true };
this.freightrules = { required: true };
this.editparams = { params: { popupHeight: '300px' }};
this.pageSettings = { pageCount: 5};
}
change(args){
}
}
|