2017-04-18 10 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' 
        }; 
       } 
       }); 
     } 
     }); 
関連する問題