当数据被加载时,我想滚动到网格的末端。但是代码不起作用。请帮帮忙
$scope.addData = function () {
var n = $scope.gridOptions.data.length + 1;
$scope.gridOptions.data.push({
"type":"student",
"is_job_ready":"true",
"is_night_shift":"true"
});
$scope.scrollTo($scope.gridOptions.data.length -1,0)
};
$scope.scrollTo = function( rowIndex, colIndex ) {
$scope.gridApi.core.scrollTo( $scope.gridOptions.data[rowIndex],$scope.gridOptions.columnDefs[colIndex]);
};发布于 2015-10-02 21:12:15
您需要在js代码中包含此模块:
ui.grid.cellNav
然后,这个卷轴就可以工作了:
$scope.gridApi.core.scrollTo($scope.gridOptions.data[$scope.gridOptions.data.length - 1], $scope.gridOptions.columnDefs[0]);
发布于 2016-05-10 04:37:13
不幸的是,似乎仍然有必要使用$timeout
例如
$timeout(function () {
// Do this after the columns and rows processors have finished and it is all rendered.
$scope.gridApi.core.scrollTo($scope.gridOptions.data[$scope.gridOptions.data.length - 1], $scope.gridOptions.columnDefs[0]);
}, 100);这甚至是在我尝试在我的代码中像这样等待modifyRows之后
gridApi.grid.modifyRows(list).then(function () {
// Do this after the columns and rows processors have finished and it is all rendered.
gridApi.selection.selectRow(list[rowIndex]);
gridApi.core.scrollTo(list[rowIndex], grid.columnDefs[0]);
});https://stackoverflow.com/questions/30566141
复制相似问题