我有这个数据网格,这是我的模板:
<dxo-paging [enabled]="true"></dxo-paging>
<dxo-editing
mode="row"
[allowUpdating]="true"
[allowDeleting]="true"
[allowAdding]="true">
</dxo-editing>
<dxi-column dataField="Cuid" caption="Cuid" [width]="130"></dxi-column>
<dxi-column dataField="Nom" caption="Nom"></dxi-column>
<dxi-column dataField="Prenom" caption="Prenom"></dxi-column>
<dxi-column
dataField="EdoID"
caption="Edo"
[width]="125"
[setCellValue]="preSelectEdo">
<dxo-lookup
[dataSource]="edos"
displayExpr="Code"
valueExpr="ID">
</dxo-lookup>
</dxi-column>
<dxi-column
dataField="ShopID"
caption="Boutique"
[width]="125"
[setCellValue]="preSelectShop">
<dxo-lookup
[dataSource]="shops"
displayExpr="Name"
valueExpr="ID">
</dxo-lookup>
</dxi-column>
</dx-data-grid>
我想获取对我的数据网格的引用并在单击按钮中获取行值:
在我的component.ts中,我试过这个:
export class myComp {
constructor(){}
@ViewChild(DxDataGridComponent) dataGrid: DxDataGridComponent;
getValueCell(rowIndex, datafield) {
this.dataGrid.instance.cellValue(rowIndex, datafield);
}
onClickBtn(){
result = this.getValueCell(1,'Name');
console.log(result);
}
}
如您所见,单击时:我得到了结果'undefined';似乎我没有正确引用数据网格
建议?