UI网scrollToFocus排序时应用到电网 [英] ui-grid scrollToFocus when sorting is applied to the grid

查看:243
本文介绍了UI网scrollToFocus排序时应用到电网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有试图将焦点设置在使用scrollToFocus方法网格中的第一行上有问题。

I've got a problem trying to set focus on the first row in a grid using the scrollToFocus method.

这个问题似乎周围的排序方向为中心:

The issue seems to be centred around the sort direction:

 sort: {
    direction: uiGridConstants.DESC
 }  

如果我离开了这一点,那么它按预期工作。我只能假设,该行数是数据的排它的分类之前,不考虑任何'后'排序。

If I leave this out then it works as expected. I can only assume that the row number is the row of the data before it's sorted and doesn't take into account any 'post' sorting.

下面是问题的一个例子: http://plnkr.co/edit/ beWci0?p = preVIEW

Here's an example of the problem: http://plnkr.co/edit/beWci0?p=preview

您会看到单击以选中它实际上去另一行第一行的时候 - 在数据集中的第一个在网格被绑定到

You'll see that when clicking to select the first row it actually goes to another row - the first in the dataset that the grid was bound to.

如何采取在考虑根据排序结果行位置任何想法?

Any ideas on how to take in to account the row position based on the sorted results?

它已经从这里修剪下来的例子放在一起:的http:// UI网.INFO /文档/#/教程/ 202_cellnav

It's been put together from trimming down the example here: http://ui-grid.info/docs/#/tutorial/202_cellnav

推荐答案

如果你想在网格中选择第一行,不论排序和过滤的,你将不得不看可见行,UI格不会呈现全部该数据阵列中的行。所以可见的行数可能比实际的数据行较小。

If you want to select first row in the grid irrespective of sorting and filtering, you will have to look at the visible rows, ui-grid does not render all the rows in the data array. So the number of visible rows may be lesser than the actual data rows.

要选择第一行就可以做到以下几点,

To select the first row you can do the following,

$scope.scrollToFocus = function( rowIndex, colIndex ) {
   var row = $scope.gridApi.grid.getVisibleRows()[rowIndex].entity;
  $scope.gridApi.cellNav.scrollToFocus( row, $scope.gridOptions.columnDefs[colIndex]);
};

这将选择一个可见行和设置重点放在第三列。
Plnkr这里 http://plnkr.co/edit/gWlY68?p=$p$pview

This will select the first visible row and set the focus on the third column. Plnkr here http://plnkr.co/edit/gWlY68?p=preview

这篇关于UI网scrollToFocus排序时应用到电网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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