forked from angular-ui/ui-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance(gridMenu): further refactor of menu logic, onclick handlers
Move handlers from column menu into grid menu, remove obsolete code, provide 'menu-hidden' event to allow better tracking of menu state. Extensions to exporter to better take advantage of grid menu.
- Loading branch information
Showing
10 changed files
with
177 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
@ngdoc overview | ||
@name Tutorial: 206 Exporting Data With Native UI | ||
@description The exporter feature allows data to be exported from the grid in | ||
csv or pdf format. The exporter can export all data, visible data or selected data. | ||
|
||
To use the exporter you need to include the ui-grid-exporter directive on | ||
your grid. If you want to export selected rows you must include the ui-grid-selection | ||
directive on your grid. If you want to export as PDF you need to have installed pdfMake, | ||
available through: | ||
<pre> bower install pdfmake </pre> | ||
|
||
The options and API for exporter can be found at {@link api/ui.grid.exporter ui.grid.exporter}. | ||
|
||
The exporter adds menu items to the grid menu, to use the native UI you need to enable | ||
the grid menu using the gridOption `enableGridMenu` | ||
|
||
@example | ||
In this example we provide a custom UI for calling the exporter, and we tailor | ||
the way the returned data behaves. | ||
|
||
<example module="app"> | ||
<file name="app.js"> | ||
var app = angular.module('app', ['ngAnimate', 'ui.grid', 'ui.grid.selection', 'ui.grid.exporter']); | ||
|
||
app.controller('MainCtrl', ['$scope', '$http', function ($scope, $http) { | ||
$scope.gridOptions = { | ||
columnDefs: [ | ||
{ field: 'name' }, | ||
{ field: 'gender', visible: false}, | ||
{ field: 'company' } | ||
], | ||
enableGridMenu: true, | ||
exporterLinkLabel: 'get your csv here', | ||
exporterPdfDefaultStyle: {fontSize: 9}, | ||
exporterPdfTableStyle: {margin: [30, 30, 30, 30]}, | ||
exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'}, | ||
exporterPdfOrientation: 'portrait', | ||
exporterPdfPageSize: 'LETTER', | ||
exporterPdfMaxGridWidth: 500, | ||
exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")), | ||
onRegisterApi: function(gridApi){ | ||
$scope.gridApi = gridApi; | ||
} | ||
}; | ||
|
||
$http.get('/data/100.json') | ||
.success(function(data) { | ||
$scope.gridOptions.data = data; | ||
}); | ||
|
||
}]); | ||
</file> | ||
|
||
<file name="index.html"> | ||
<div ng-controller="MainCtrl"> | ||
<div class="custom-csv-link-location"> | ||
<label>Your CSV will show below:</label> | ||
<span class="ui-grid-exporter-csv-link"> </span> | ||
</div> | ||
|
||
<div ui-grid="gridOptions" ui-grid-selection ui-grid-exporter class="grid"></div> | ||
</div> | ||
</file> | ||
|
||
<file name="main.css"> | ||
.grid { | ||
width: 500px; | ||
height: 400px; | ||
} | ||
</file> | ||
</example> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.