角度 ui-grid 线选择不起作用 [英] Angular ui-grid line selection is not working

查看:29
本文介绍了角度 ui-grid 线选择不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Angular ui-grid 选择第一条渲染线,但它不起作用.这是一个带有示例的 plunker.我能够在从服务器渲染数据后使用超时来完成它,但不能使用 $scope.gridApi.grid.modifyRows($scope.gridOptions.data);$scope.gridApi.selection.selectRow($scope.gridOptions.data[0]); 如不同示例所示.你能帮我修一下吗?

I'm trying to select the first rendred line using Angular ui-grid but it's not working. Here is a plunker with the example. I was able to do it using timeout after rendering data from the server but not using $scope.gridApi.grid.modifyRows($scope.gridOptions.data); $scope.gridApi.selection.selectRow($scope.gridOptions.data[0]); as shown in different example. would you please help me fixing it?

推荐答案

如果数据是通过异步调用加载的,您可以在回调中选择行,您可以使用 $scope.gridApi,因为您将其保存在 onRegisterApi 中功能.

If the data is getting loaded by an async call you can select the rows in the callback, you can use $scope.gridApi since you saved it in the onRegisterApi function.

请找到plunker

$http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json')
    .success(function (data) {
        $scope.gridOptions.data = data;
        $scope.gridApi.grid.modifyRows($scope.gridOptions.data);
        $scope.gridApi.selection.selectRow($scope.gridOptions.data[0]);
    });

这篇关于角度 ui-grid 线选择不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆