[英]How to access the sorted rows in an Angular UI Grid?
I am using the Angular UI Grid to display some data. 我使用Angular UI Grid来显示一些数据。 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. 我能够选择一行,并按行“按名称”列按照配置的升序排序。
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: 如UI网格教程210中所示 ,我添加了逻辑,以在我的数据加载并添加到网格后自动选择第一个项目:
datacontext.getAllGcTab(vm.filter).then(function (result) {
vm.gridOptions.data = result.results;
vm.gridApi.selection.selectRow(vm.gridOptions.data[0]);
});
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.
我的网格中有大约500个项目,这些项目并不多,并且表现良好,但在这种情况下,所选项目位于线下并且不可见。
Is there any option to directly access the rows or the sorted data of the UI Grid? 有没有选项可以直接访问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()
以当前排序/过滤器顺序返回行数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.