2016-04-27 51 views
2

我從服務獲取嵌套集合。當我將字段映射到數組與Array.length它給我輸出。但當我嘗試 字段:Auditlogs[Auditlogs.length-1].auditState.StateName。它停止工作。請幫助我。在Angular UI-Grid中解析數組長度並動態啓用/禁用分頁

我還想要根據$scope中的標誌禁用分頁。下面是我的UI網格設置

$scope.gridOptions = { 
    data: 'auditList', 
    enableColumnResizing: true, 
    paginationPageSizes: [10, 25, 50], 
    paginationPageSize: 10, 
    enablePaginationControls: false, 
    enableFiltering: false, 
    enableSorting: true,  
    useExternalPagination: true, 
    columnDefs: [ 
     { 
      name: 'LOAN #', 
      cellTemplate: '<a ng-click="grid.appScope.getLoanDetails(row.entity.Loan.LoanNumber,row.entity.Id)">{{row.entity.Loan.LoanNumber}}</a>' 
      ,enableHiding: false 
     }, 
     { 
      name: 'Audit Type', 
      field: 'AuditType.AuditType1' 
      ,enableHiding: false 
     }, 
     { 
      name: 'Borrower Last Name', 
      field: 'Loan.BorrowerLastName' 
      ,enableHiding: false 
     }, 
     { 
      name: 'Funding Date', 
      field: 'Loan.FundingDate', 
      type: 'date', 
      cellFilter: 'date:\'MM/dd/yyyy\'', 
      enableFiltering: false 
      ,enableHiding: false 
     }, 
     { 
      name: 'Audit start date', 
      field: 'AuditStartDate', 
      type: 'date', 
      cellFilter: 'date:\'MM/dd/yyyy\'' 
      ,enableHiding: false 
     }, 
     { 
      name: 'Due Date', 
      field: 'AuditStartDate', 
      type: 'date', 
      cellFilter: 'date:\'MM/dd/yyyy\'' 
      ,enableHiding: false 
     }, 
     { 
      name: 'Finding Count',     
      field: 'AuditFindings.length', 
      enableHiding: false 
     }, 
     { 
      name: 'Current Status', 
      field: 'Auditlogs[Auditlogs.length-1].auditState.StateName'     
//$scope.auditList[0].Auditlogs[$scope.auditList[0].Auditlogs.length-1].auditState.StateName 
      ,enableHiding: false 
     }, 
     { 
      name: 'Cur.Status Dt.', 
      field: 'AuditStartDate', 
      type: 'date', 
      cellFilter: 'date:\'MM/dd/yyyy\'' 
      ,enableHiding: false 
     } 
    ], 
    onRegisterApi: function (gridApi) { 
     $scope.gridApi = gridApi; 
     gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) { 
      $scope.paginationOptions.pageNumber = newPage; 
      $scope.paginationOptions.pageSize = pageSize; 
      $scope.getAllPA($scope.flagValue.value); 
     }); 
    } 
}; 
+0

您能否提供完整的控制器,服務代碼或plunkr? –

回答

0

我用CellTemplate代替費爾德

cellTemplate: '<div>{{row.entity.Auditlogs[row.entity.Auditlogs.length-1].auditState.StateName}}</div>' 

我還在尋找到動態啓用網格/禁用分頁解決了上述問題。

+0

已修復通過將標誌存儲在範圍中並將範圍值指定給網格選項實現動態分頁 –