加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 如何在角度ui.grid中找到已排序的列和按什么顺序排

发布时间:2020-12-17 17:04:24 所属栏目:安全 来源:网络整理
导读:如何在角度ui.grid中找到已排序的列和按什么顺序排列.其实我想设置基于服务器的分页.为此,我将params中的数据发送为{pageNumber,pageSize,column,order}.现在如何找到用户已经排序的列(名称/年龄/数字)以及角度ui.grid中的顺序(ASC / DESC) 解决方法 当列已
如何在角度ui.grid中找到已排序的列和按什么顺序排列.其实我想设置基于服务器的分页.为此,我将params中的数据发送为{pageNumber,pageSize,column,order}.现在如何找到用户已经排序的列(名称/年龄/数字)以及角度ui.grid中的顺序(ASC / DESC)

解决方法

当列已排序时,Angular ui-grid会启动sortChanged事件.
您还必须将useExternalSorting显式设置为true.

您可以在onRegisterApi函数的gridOptions中捕获此事件,并处理回调函数中的排序逻辑,该函数将网格和排序列数组作为参数,如下所示:

$scope.gridOptions = {
    useExternalSorting: true,columnDefs: [
       ...
    ],onRegisterApi: function( gridApi ) {
      $scope.gridApi = gridApi;
      $scope.gridApi.core.on.sortChanged( $scope,function(grid,sortColumns){

          // sortColumns is an array containing just the column sorted in the grid
          var name = sortColumns[0].name; // the name of the first column sorted
          var direction = sortColumns[0].sort.direction // the direction of the first column sorted: "desc" or "asc"

          // Your logic to do the server sorting
      });
    }
};

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读