2017-09-25 27 views
0

rowData 및 columnDefs를 소품으로 전달합니다. 그리드가 제대로로드되고 있습니다. 그러나 데이터가 변경되면 Grid가 다시 렌더링되지 않습니다. 부모 구성 요소의 렌더링으로 이동하여 AgGridReact로 전달됩니다. 그러나 여전히 다시 렌더링되지 않습니다. 그것은 완전한 응용 프로그램을 반응이기 때문에AgGridReact 데이터 변경시 다시 렌더링하지 않음

, 내가 추가 한 코드는 https://github.com/jintoppy/ag-grid-upgrade

홈페이지 코드에 아래와 같습니다.

<AgGridReact 
     // properties 
     columnDefs={this.state.columnDefs} 
     rowData={this.props.data} 

     // events 
     onGridReady={this.onGridReady}> 
</AgGridReact> 

답변

0

해결 방법이 있는지 여부는 확실하지 않습니다. 나는 이것을위한 해결책이있다.

rosData를 AgGridReact로 전달할 때도이 문제가 발생했습니다. 그런 다음 setRowData (행) API 함수를 사용하여 행을 업데이트하려고했습니다.

그리드가 준비되면 gridOptions에는 api도 포함되어 있으므로 gridOptions.api를 호출하여 Ag-grid API에 액세스하거나 아래의 onGridReady 메소드에서 this.api를 만들 수 있습니다.

onGridReady (params) { const rowData = this.props.rows;

this.api = params.api; 

if (rowData.length > 0 && this.api) { 
    this.api.setRowData(rowData); 
} 

}

당신은

componentWillReceiveProps(nextProps) { 

    if (!isEqual(this.props.rows, nextProps.rows) && this.api) { 

     this.api.setRowData(nextProps.rows); 
    } 
    } 

는 다음 구성 요소에서이 도움이

<AgGridReact 
    // properties 
    columnDefs={this.state.columnDefs} 

    // events 
    onGridReady={this.onGridReady}> 
</AgGridReact> 

희망을 rowData 하행 소품을 제거 할 수 있습니다 componentWillReceiveProps에 samething를 호출 할 필요가 ...