Here Id is static string ‘StaticGridId’. I can get jqxGridComponent via decorator @ViewChild(‘StaticGridId’). Then I can work with the grid. For example, this.myGrid.getselectedrowindex(). This code works fine:
template:'
<jqxGrid #StaticGridId
[width]="'100%'"
[source]="source"
[columns]="columns"
</jqxGrid>';
export class GridComponent {
@Input() private source: any;
@Input() private columns: any;
@ViewChild(‘StaticGridId’) myGrid: jqxGridComponent;
public getRecordId ():string {
return this.myGrid.getselectedrowindex()
}
}
But I need to use variable id for elements. I try to do this:
template:'
<jqxGrid #{{elementId}} <!-— can I do that? -->
[width]="'100%'"
[source]="source"
[columns]="columns"
</jqxGrid>';
export class GridComponent {
@Input() private elementId: string;
@Input() private source: any;
@Input() private columns: any;
@ViewChild(this.elementId) myGrid: jqxGridComponent; // here I get an error
public getRecordId ():string {
return this.myGrid.getselectedrowindex()
}
}
How to work jqx component with variable Id ?