【问题标题】:using expandable Angular js ui grid使用可扩展的 Angular js ui 网格
【发布时间】:2016-10-26 09:06:12
【问题描述】:

我正在使用可扩展 UI 网格。

我的数据显示在网格中,单击时会展开,网格每 5 秒刷新一次。

如果我展开一行,那么它会随着网格的刷新每 5 秒折叠一次。

如何在网格刷新时保持行扩展?

代码

$scope.fillProductList = function () {
  $http({
    method: 'GET',
    url: getJobs,
    data: {}
  }).success(function (result) {

    $scope.showSubListGrid = false;
    $scope.myData = '';
    var gridDataWithDownload = result;

    //grid data
    $scope.myData = gridDataWithDownload;

    $scope.gridOptionsCategory.data = gridDataWithDownload;

    //   $scope.refresh = false;
    timer = $timeout(function () {
      $scope.fillProductList();
    }, timeOutStamp);

  }).error(function (result) {

    timer = $timeout(function () {
      $scope.fillProductList();
    }, timeOutStamp);

  });
};

$scope.gridOptionsCategory = {
  useExternalPagination: true,
  expandableRowHeight: 300,

  enableSorting: true,
  data: $scope.myData,

  enableColumnResizing: true,
  enableGridMenu: false,
  expandableRowTemplate: 'griddata.html',

  onRegisterApi: function (gridApi) {
    $scope.gridApi = gridApi;

    //  gridApi.expandable.toggleRowExpansion($scope.gridApi.grid.row[0].entity);
    gridApi.expandable.on.rowExpandedStateChanged($scope, function (row) {

      $scope.gridApi.grid.modifyRows($scope.gridOptionsCategory.data);
      $scope.gridApi.selection.selectRow($scope.gridOptionsCategory
        .data[0]);
      //$scope.gridOptionsCategory.expandableRowHeight = 500;
      //$timeout.cancel(timer);                     
      if (row.isExpanded) {

        row.entity.components = JSON.parse(row.entity.components)
        this.scope.gridOptionsCategory.expandableRowScope = row.entity;
        // $scope.GridOptions.expandableRowScope = row.entity.components;

      }
      if (!row.isExpanded) {
        timer = $timeout(function () {
          $scope.fillProductList();
        }, timeOutStamp);

      }
    });

  },
  enableHorizontalScrollbar: 0,
  //enableVerticalScrollbar:0,

  //useExternalSorting: true,
  columnDefs: [{
      field: 'filtertoggle',
      displayName: '',
      visible: true,
      headerCellTemplate: '' +
        '<button id=\'toggleFiltering\' style= "padding:3px 7px;" ng-click="grid.appScope.toggleFiltering()" class="btn btn-warning glyphicon glyphicon-filter">' +
        '</button>'
    },
    {
      name: 'Job Name',
      field: 'name',

      width: '20%',
      enableCellEdit: false,
      enableHiding: true,
      enableGrouping: false,

      //    enableFiltering: true,
      filter: {
        term: $scope.filterOptions.filterText
      }
    },
    {
      name: 'Profile',
      field: 'profile',
      width: '15%',
      enableCellEdit: false,
      enableHiding: true,
      enableGrouping: false
    }, {
      name: 'Progress',
      field: 'progress',
      enableSorting: true,
      width: '18%',
      enableCellEdit: false,
      enableHiding: true,
      enableGrouping: false,
      //    enableFiltering: true,                      
      cellTemplate: statusTemplate
    }
  ]
};

【问题讨论】:

  • 有人请回复

标签: angularjs angular-ui-grid expandable


【解决方案1】:
gridApi.core.on.rowsRendered(scope,() => {
        if (!gridApi.grid.expandable.expandedAll && !initialized)                 
{   gridApi.expandable.expandAllRows();
            initialized = true;
         }
});

你能检查一下这些代码吗?你可能会有一些想法。

【讨论】:

  • 它扩展所有行。我的问题是扩展行不应该通过递归网格调用关闭
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-11-26
  • 2020-03-25
  • 1970-01-01
  • 1970-01-01
  • 2012-05-28
  • 1970-01-01
  • 2018-02-28
相关资源
最近更新 更多