How do I scroll an ngGrid to show the current selection?

前端 未结 4 1654
甜味超标
甜味超标 2021-02-04 13:15

I\'m setting the selection of my ngGrid from JavaScript, calling gridOptions.selectItem(). I have multiSelect set to false, so there is only ever one row selected.

4条回答
  •  野的像风
    2021-02-04 14:00

    I found the accepted answer above is not working with the latest version of ui-grid (v4.0.4 - 2017-04-04).

    Here is the code I use:

    $scope.gridApi.core.scrollTo(vm.gridOptions.data[indexToSelect]);
    

    In gripOptions, you need to register the gridApi in onRegisterApi.

    onRegisterApi: function (gridApi) {
       $scope.gridApi = gridApi;
    },
    

提交回复
热议问题