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