如何访问排序行以角的UI网格? [英] How to access the sorted rows in an Angular UI Grid?

查看:174
本文介绍了如何访问排序行以角的UI网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是角UI电网来显示一些数据。排序已启用并初始化,以及选择一个单行:

I am using the Angular UI Grid to display some data. Sorting is enabled and initialized as well as selecting a single row:

vm.gridOptions = {
    enableSorting: true,
    enableRowSelection: true,
    multiSelect: false,
    noUnselect: true,
    columnDefs: [
        { name: '#', field: 'ID' },
        { name: 'Name', field: 'CODE', sort: { direction: 'asc', priority: 1 } },
        { name: 'Comment', field: 'DESCR' },
    ],
    data: []
};

我可以选择行和行是按照升序排列名称列排序的配置。

I am able to select a row and the rows are sorted by the "Name" column in ascending order as configured.

作为href=\"http://ui-grid.info/docs/#/tutorial/210_selection\"> UI电网教程210 ,我已经添加了逻辑,能够自动选择第一项的

As shown in the UI Grid Tutorial 210, I have added logic to automatically select the first item after my data has been loaded and added to the grid:

datacontext.getAllGcTab(vm.filter).then(function (result) {
    vm.gridOptions.data = result.results;
    vm.gridApi.selection.selectRow(vm.gridOptions.data[0]);
});

但是,这code是选择未排序的数据的第一项。有在我的网格,这是不多,表现良好约500个项目,但在这种情况下,所选择的项目是某处向下行和不可见的。

But this code is selecting the first item of the unsorted data. There are about 500 items in my grid, which is not much and performs well, but in this case the selected item is somewhere down the line and invisible.

是否有任何选项,直接访问的行或用户界面网格的排序的数据

Is there any option to directly access the rows or the sorted data of the UI Grid?

我知道,外部排序可以解决这个问题,因为这样我就已经排序的数据分配给电网。但是,这在我看来是不必要的开销...

I know that external sorting could solve that problem, because then I would assign the already sorted data to the grid. But this seems to me like an unnecessary overhead...

推荐答案

$ scope.gridApi.core.getVisibleRows()在当前排序返回行的数组/滤波器的阶数。

$scope.gridApi.core.getVisibleRows() returns an array of rows in the current sort/filter order.

这篇关于如何访问排序行以角的UI网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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