|
7 | 7 | .right { |
8 | 8 | float: right; |
9 | 9 | } |
10 | | - |
11 | 10 | #exportButton { |
12 | 11 | float: left; |
13 | 12 | } |
| 13 | + .exporting-overlay { |
| 14 | + position: absolute; |
| 15 | + background-color: rgba(181, 181, 181, 0.9); |
| 16 | + top: 0; |
| 17 | + left: 0; |
| 18 | + z-index: 100000; |
| 19 | + text-align: center; |
| 20 | + vertical-align: top; |
| 21 | + } |
| 22 | + .exporting-overlay:after { |
| 23 | + content: ""; |
| 24 | + display: inline-block; |
| 25 | + vertical-align: middle; |
| 26 | + height: 100%; |
| 27 | + } |
| 28 | + .exporting-text { |
| 29 | + font-size: 46px; |
| 30 | + font-weight: bold; |
| 31 | + } |
14 | 32 | </style> |
15 | 33 | <!--Required scripts--> |
16 | 34 | <script src="%%modernizr%%"></script> |
|
28 | 46 | $.ig.loader({ |
29 | 47 | scriptPath: "%%ignite-ui%%/js/", |
30 | 48 | cssPath: "%%ignite-ui%%/css/", |
31 | | - resources: 'igGrid,' + |
32 | | - 'igGrid.Hiding,' + |
33 | | - 'igGrid.Filtering,' + |
34 | | - 'igGrid.Sorting,' + |
35 | | - 'igGrid.Paging,' + |
36 | | - 'igGrid.Summaries,' + |
37 | | - 'modules/infragistics.documents.core.js,' + |
38 | | - 'modules/infragistics.excel.js,' + |
39 | | - 'modules/infragistics.gridexcelexporter.js' |
| 49 | + resources: 'igGrid.Sorting.Filtering,' + |
| 50 | + 'igGridExcelExporter' |
40 | 51 | }); |
41 | 52 |
|
42 | 53 | $.ig.loader(function () { |
43 | 54 | var data = [ |
44 | | - { 'ProductID': 1, 'Name': 'Omnis ut illum nisi.', 'ProductNumber': 2973311236, "InStock": true, "Quantity": 56, VendorWebsite: 'http://infragistics.com/', }, |
45 | | - { 'ProductID': 2, 'Name': 'Quis quibusdam qui.', 'ProductNumber': 5907101619, "InStock": false, "Quantity": 0, VendorWebsite: 'http://infragistics.com/', }, |
46 | | - { 'ProductID': 3, 'Name': 'Sint laudantium et.', 'ProductNumber': 3057803521, "InStock": true, "Quantity": 26, VendorWebsite: 'http://infragistics.com/' }, |
47 | | - { 'ProductID': 17, 'Name': 'Tempore eos.', 'ProductNumber': 3576608248, "InStock": true, "Quantity": 8, VendorWebsite: 'http://infragistics.com/' }, |
48 | | - { 'ProductID': 18, 'Name': 'Maiores aut ducimus.', 'ProductNumber': 7079645227, "InStock": true, "Quantity": 62, VendorWebsite: 'http://infragistics.com/' }, |
49 | | - { 'ProductID': 19, 'Name': 'Vel inventore.', 'ProductNumber': 191484500, "InStock": true, "Quantity": 18, VendorWebsite: 'http://infragistics.com/' }, |
50 | | - { 'ProductID': 20, 'Name': 'Ut molestiae.', 'ProductNumber': 2994899561, "InStock": false, "Quantity": 0, VendorWebsite: 'http://infragistics.com/' }, |
51 | | - { 'ProductID': 31, 'Name': 'Nihil magnam aut ut.', 'ProductNumber': 5652753011, "InStock": true, "Quantity": 41, VendorWebsite: 'http://infragistics.com/' }, |
52 | | - { 'ProductID': 32, 'Name': 'Repellendus dolorum.', 'ProductNumber': 8807902556, "InStock": true, "Quantity": 10, VendorWebsite: 'http://infragistics.com/' }, |
53 | | - { 'ProductID': 43, 'Name': 'Odit ut quo minus.', 'ProductNumber': 1083007847, "InStock": false, "Quantity": 0, VendorWebsite: 'http://infragistics.com/' } |
| 55 | + { 'Name': 'Omnis ut illum nisi.', 'ProductNumber': 2973311236, "InStock": true, "Quantity": 56, VendorWebsite: 'http://infragistics.com/', DeliveryDate: "07/25/2015" }, |
| 56 | + { 'Name': 'Quis quibusdam qui.', 'ProductNumber': 5907101619, "InStock": false, "Quantity": 0, VendorWebsite: 'http://infragistics.com/', DeliveryDate: "09/22/2014" }, |
| 57 | + { 'Name': 'Sint laudantium et.', 'ProductNumber': 3057803521, "InStock": true, "Quantity": 26, VendorWebsite: 'http://infragistics.com/', DeliveryDate: "08/13/2015" }, |
| 58 | + { 'Name': 'Tempore eos.', 'ProductNumber': 3576608248, "InStock": true, "Quantity": 8, VendorWebsite: 'http://infragistics.com/', DeliveryDate: "06/28/2014" }, |
| 59 | + { 'Name': 'Maiores aut ducimus.', 'ProductNumber': 7079645227, "InStock": true, "Quantity": 62, VendorWebsite: 'http://infragistics.com/', DeliveryDate: "04/19/2015" }, |
| 60 | + { 'Name': 'Vel inventore.', 'ProductNumber': 191484500, "InStock": true, "Quantity": 18, VendorWebsite: 'http://infragistics.com/', DeliveryDate: "07/21/2015" }, |
| 61 | + { 'Name': 'Ut molestiae.', 'ProductNumber': 2994899561, "InStock": false, "Quantity": 0, VendorWebsite: 'http://infragistics.com/', DeliveryDate: "03/10/2016" }, |
| 62 | + { 'Name': 'Nihil magnam aut ut.', 'ProductNumber': 5652753011, "InStock": true, "Quantity": 41, VendorWebsite: 'http://infragistics.com/', DeliveryDate: "07/25/2016" }, |
| 63 | + { 'Name': 'Repellendus dolorum.', 'ProductNumber': 8807902556, "InStock": true, "Quantity": 10, VendorWebsite: 'http://infragistics.com/', DeliveryDate: "09/01/2017" }, |
| 64 | + { 'Name': 'Odit ut quo minus.', 'ProductNumber': 1083007847, "InStock": false, "Quantity": 0, VendorWebsite: 'http://infragistics.com/', DeliveryDate: "11/10/2015" } |
54 | 65 | ]; |
55 | 66 |
|
56 | 67 | $("#grid").igGrid({ |
57 | 68 | autoGenerateColumns: false, |
58 | 69 | columns: [ |
59 | | - { headerText: "$$(ProductID)", key: "ProductID", dataType: "number", width: "100px" }, |
60 | 70 | { headerText: "$$(Name)", key: "Name", dataType: "string", width: "250px" }, |
61 | 71 | { headerText: "$$(ProductNumber)", key: "ProductNumber", dataType: "number", width: "200px" }, |
62 | 72 | { headerText: "$$(InStock)", key: "InStock", dataType: "bool", width: "150px" }, |
63 | 73 | { headerText: "$$(Quantity)", key: "Quantity", dataType: "number", width: "150px" }, |
64 | | - { headerText: "$$(Vendorwebsite)", key: "VendorWebsite", width: "220px", template: '<a href="${VendorWebsite}">${VendorWebsite}</a>' } |
| 74 | + { headerText: "$$(Vendorwebsite)", key: "VendorWebsite", width: "220px", template: '<a href="${VendorWebsite}">${VendorWebsite}</a>' }, |
| 75 | + { headerText: "$$(DeliveryDate)", key: "DeliveryDate", dataType: "date", width: "200px" }, |
65 | 76 | ], |
66 | 77 | dataSource: data, |
67 | 78 | width: "100%", |
68 | | - primaryKey: "ProductID", |
69 | 79 | features: [ |
70 | | - { |
71 | | - name: "Filtering" |
72 | | - }, |
73 | | - { |
74 | | - name: "Sorting", |
75 | | - }, |
76 | | - { |
77 | | - name: "Paging", |
78 | | - type: "local", |
79 | | - pageSize: 10 |
80 | | - }] |
| 80 | + { |
| 81 | + name: "Filtering" |
| 82 | + }, |
| 83 | + { |
| 84 | + name: "Sorting", |
| 85 | + } |
| 86 | + ] |
81 | 87 | }); |
82 | 88 |
|
83 | 89 | $("#exportButton").on("click", function () { |
| 90 | + var exportingOverlay = $('<div>'); |
84 | 91 | $.ig.GridExcelExporter.exportGrid($("#grid"), { |
85 | 92 | fileName: "igGrid", |
86 | | - gridFeatureOptions: { "sorting": "applied", "filtering": "applied", paging: "currentPage", "summaries": "applied" }, |
| 93 | + gridFeatureOptions: { sorting: "applied", filtering: "applied" }, |
87 | 94 | }, |
88 | 95 | { |
89 | | - headerCellExported: function (e, args) { |
90 | | - if (args.columnKey == "Quantity") { |
91 | | - args.xlRow.setCellValue(args.columnIndex, "$$(AvailableQuantity)"); |
92 | | - } |
| 96 | + exportStarting: function (e, args) { |
| 97 | + showOverlay(args.grid, exportingOverlay); |
93 | 98 | }, |
94 | | - cellExporting: function (e, args) { |
95 | | - if (args.columnKey == "Quantity" && args.cellValue > 15) { |
96 | | - args.xlRow.getCellFormat(args.columnIndex).font().bold(1); |
97 | | - } |
| 99 | + success: function () { |
| 100 | + hideOverlay(exportingOverlay); |
98 | 101 | }, |
99 | 102 | cellExported: function (e, args) { |
100 | 103 | if (args.xlRow.index() == 0) { |
101 | 104 | return; |
102 | 105 | } |
| 106 | + if (args.columnKey == "Quantity" && args.cellValue > 15) { |
| 107 | + args.xlRow.getCellFormat(args.columnIndex).font().bold(1); |
| 108 | + args.xlRow.getCellFormat(args.columnIndex).fill($.ig.excel.CellFill.createLinearGradientFill(45, '#FF0000', '#00FFFF')); |
| 109 | + } |
103 | 110 | if (args.columnKey == 'VendorWebsite') { |
104 | 111 | var xlRow = args.xlRow; |
105 | 112 | xlRow.cells(args.columnIndex).applyFormula('=HYPERLINK("' + args.cellValue + '")'); |
106 | 113 | } |
107 | 114 | }, |
108 | | - rowExported: function (e, args) { |
109 | | - if (args.xlRow.index() == args.grid.igGrid("allRows").length - 1) { |
110 | | - $('<div style="font-size:20px;">$$(LastRowExported)</div>').insertBefore('#exportButton').delay(1000).fadeOut(); |
111 | | - } |
112 | | - } |
| 115 | + exportEnding: function (e, args) { |
| 116 | + args.worksheet.columns().item(5).cellFormat().formatString("dd/MMM/YYYY"); |
| 117 | + }, |
113 | 118 | }); |
114 | 119 | }); |
115 | 120 | }); |
| 121 | + |
| 122 | + function showOverlay(grid, exportingOverlay) { |
| 123 | + var $gridContainer = $('#' + grid.attr('id') + '_container'); |
| 124 | + |
| 125 | + exportingOverlay.css({ |
| 126 | + "width": $gridContainer.outerWidth(), |
| 127 | + "height": $gridContainer.outerHeight() |
| 128 | + }).html('<span class="exporting-text">Exporting...</span>'); |
| 129 | + exportingOverlay.addClass("exporting-overlay"); |
| 130 | + |
| 131 | + $gridContainer.append(exportingOverlay); |
| 132 | + } |
| 133 | + |
| 134 | + function hideOverlay(exportingOverlay) { |
| 135 | + exportingOverlay.remove(); |
| 136 | + } |
116 | 137 | </script> |
117 | 138 | </head> |
118 | 139 | <body> |
|
0 commit comments