2016-10-26 6 views
0

私はExpandable UI Gridを使用しています。拡張可能なAngular js 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 
    } 
    ] 
}; 
+0

誰かが – cheeku

答えて

0
gridApi.core.on.rowsRendered(scope,() => { 
     if (!gridApi.grid.expandable.expandedAll && !initialized)     
{ gridApi.expandable.expandAllRows(); 
      initialized = true; 
     } 
}); 

あなたはこれらのコードで確認することができます。あなたはいくつかの考えを得るかもしれません。

+0

のすべての行を展開して返信してください。私の問題は拡大された行は、再帰的なグリッド呼び出しで閉じられてはならない – cheeku

関連する問題