2017-07-27 10 views
0

UIグリッド/角度1.5を使用しているため、uiグリッドcsvエクスポートの最後に2行を追加する必要があります。エクスポートする前にコールバックを試みましたが、正しいロジックを実行できません。誰もが任意のヒント?UIグリッドに余分な行を追加する

$scope.gridOptions.exporterFieldCallback = function(grid, row, col, value) { 
    grid.rows[grid.rows.length] = 'Hello \n World' 
} 

答えて

0

私はまだUIグリッドを使用していませんが、試してみましょう。

私の理解として、エクスポートされたCSVファイルに2つの新しい行を追加したいとします。

exporterFieldCallbackに行を追加したいのですが、その行にはそのコールバックが実行されます。=> 10行、10回=> 10行×2行= 20行それはあなたが期待していないものです。

私たちはこの

$scope.export = function() { 
    $scope.gridOptions.data.push({ 
     "name": "Hello world", 
     "gender": 1, 
     "company": "test company" 
    }); 
    $timeout(function() {//$timeout denote that you will wait for angular to complete their digest + render before call the exportation = you give UI grid to prepare NEW data before export it. 
     if ($scope.export_format == 'csv') { 
      var myElement = angular.element(document.querySelectorAll(".custom-csv-link-location")); 
      $scope.gridApi.exporter.csvExport($scope.export_row_type, $scope.export_column_type, myElement); 
     } else if ($scope.export_format == 'pdf') { 
      $scope.gridApi.exporter.pdfExport($scope.export_row_type, $scope.export_column_type); 
     }; 
    }) 
}; 
のようなエクスポート機能を変更するドキュメント+ plunker here

を持っています

関連する問題