에서 정의되지 않은. 여기AG-그리드 gridOptions.api 내가, 타이프 라이터와 angular2에 AG-그리드를 시도하고 몇 가지 이유로 내가 정의되지 않은 오류가의 AG-그리드 API를 사용할 수 없습니다입니다 각 2
입니다 코드 ..
import { AgRendererComponent } from 'ag-grid-ng2/main';
import { GridOptions, RowNode } from 'ag-grid/main';
import { GridOptionsWrapper } from 'ag-grid/main';
import { GridApi } from 'ag-grid/main';
public gridOptions: GridOptions;
constructor()
{
this.gridOptions = <GridOptions>{};
alert(this.gridOptions);
alert(this.gridOptions.api); // *** getting undefined ***
this.gridOptions = <GridOptions>{
columnDefs: this.columnDefs(),
rowData: this.rowData,
onSelectionChanged: this.onSelectionChanged,
groupSelectsChildren: true,
suppressRowClickSelection: true,
rowSelection: 'multiple',
enableColResize: true,
enableSorting: true,
rowHeight: 45}
}//constructor
알려 주시기 바랍니다, 감사합니다
는
onGridReady() {
console.log(this.gridOptions.api); // here it work
this.selectedRows = this.gridOptions.api.getSelectedRows();
console.log(this.selectedRows);
}
private testClick(event): void {
try {
console.log(this.gridOptions.api); // here gives error
this.selectedRows = this.gridOptions.api.getSelectedRows();
console.log(this.selectedRows); //getting error saying undefined
}
}
아래에 의견을 코드로 업데이트
귀하의 답변 주셔서 모두 감사합니다 onGridReady() { 을 console.log (this.gridOptions.api).; // here it works this.selectedRows = this.gridOptions.api.getSelectedRows(); console.log (this.selectedRows); } private testClick (이벤트) : void { { console.log (this.gridOptions.api); // 여기에 오류가 발생합니다. this.selectedRows = this.gridOptions.api.getSelectedRows(); console.log (this.selectedRows); // 정의가 없다는 에러가 발생합니다 } 이 흥미로운 문제에 대해 저를 도우십시오 – Sankaranarayanan
언제 testClick을 호출합니까? 사용자 중심인가? –