ag-grid server side infinite scrolling accessing props

前端 未结 1 1415
半阙折子戏
半阙折子戏 2021-01-26 04:10

I\'m attempting to implement ag-grid server side row model as described in their documentation here. What I\'m attempting to do is pass the api call along with it\'s parameters

相关标签:
1条回答
  • 2021-01-26 04:59

    You need to use Arrow function to access the properties of the parent scope. Check the code below for getRows and setTimeout.

      var dataSource = {
        rowCount: null,
        getRows: (params) => {
          setTimeout(() => {
            let serviceParams = this.props.dataServiceParams ?  this.props.dataServiceParams.slice() : {};
            serviceParams.pageSize = this.state.paginationPageSize; // this will be the rows returned per service call
            serviceParams.index =  // if there is more than 1 page for the pagesize this is the index/page to return.
            serviceParams.sortAndFilters = gridUtility.combineSortAndFilters(params.sortModel, params.filterModel);
    
            this.props.dataService(serviceParams)
                .then(out => {
                  var rowsThisPage = out;
                  var lastRow = -1;
                  params.successCallback(rowsThisPage, lastRow);
                });
    
            params.context.componentParent.gridApi.hideOverlay();
          }, 500);
        }
      };
    
    0 讨论(0)
提交回复
热议问题