2017-04-18 14 views
0

셀에서 테이블 내용을 오른쪽 정렬하려고합니다. AngularJS 내에서 pdfmake를 사용하여 데이터를 내보내고 있습니다.UI 격자 AngularJS : 셀 필터가 테이블 데이터를 재정렬합니다

왼쪽에있는 테이블 데이터에이 필터를 적용하면 테이블 데이터가 정렬됩니다. exporterPdfAlign: 'right' 각 열 내의 모든 콘텐츠를 정렬이 필터없이

app.filter('rentalFilter', function() { 
    return function (value, scope) { 
    // Only perform logic if the value is actually defined 
    if(typeof value != 'undefined') { 
     if(value == null || value == "") 
      value = 0; 
     value = value.toFixed(2); 
     if(value >= 0) { 
      var parts=value.toString().split("."); 
      return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (parts[1] ? "." + parts[1] : ""); 
     } 
     else { 
      value = value * -1.00; 
      value = value.toFixed(2); 
      var parts=value.toString().split("."); 
      return "-" + parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (parts[1] ? "." + parts[1] : ""); 
     } 
    } 
    }; 
}); 

: 여기 필터이다.

{ 
     name : 'mondayNet', 
     displayName : 'Net', 
     category : "MONDAY", 
     exporterPdfAlign: 'right', 
     width : '14%', 
     cellTemplate : 'app/views/common/templates/cell/pos-neg-cell-template.html', 
     footerCellTemplate : '<div class="ui-grid-cell-contents text-center" ng-class="{positive : col.getAggregationValue() > 0, negative : col.getAggregationValue() < 1}">{{col.getAggregationValue() | number : 2}}</div>', 
     aggregationType : uiGridConstants.aggregationTypes.sum, 
     enableColumnMenu : false 
    }, 

필터 내에서 텍스트의 올바른 맞춤을 적용하려면 어떻게해야합니까? PDF로 모든 데이터를 내보내는 것입니다

$scope.export() 

내 감사

답변

0

, 난이 추가 된 그 권리는 각 열 아래에있는 모든 데이터를 정렬합니다

var alignRight = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; 
     angular.forEach(content.content[0].table.body, function(row, rowIndex) { 
     if (rowIndex !== 0) { 
      angular.forEach(row, function(column, columnIndex) { 

       if (alignRight.indexOf(columnIndex) !== -1) { 

        content.content[0].table.body[rowIndex][columnIndex] = { 
          text: content.content[0].table.body[rowIndex][columnIndex], 
          alignment: 'right' 
        }; 
       } 
       }); 
     } 
     });