GridExporterButton.js (1875B)
1 Ext.define("PartKeepr.Exporter.GridExporterButton", { 2 extend: "Ext.button.Button", 3 4 genericExporter: true, 5 6 initComponent: function () 7 { 8 this.menu = [ 9 { 10 text: i18n("Export Grid"), 11 menu: [ 12 { 13 text: i18n("CSV"), 14 handler: "onCSVExport", 15 scope: this 16 }, { 17 text: i18n("Excel 2007 and later"), 18 handler: "onExcelExport", 19 scope: this 20 } 21 ] 22 } 23 ]; 24 25 if (this.genericExporter) { 26 this.menu.push({ 27 text: i18n("Custom Export…"), 28 handler: "onCustomExport", 29 scope: this 30 }); 31 } 32 this.callParent(arguments); 33 }, 34 onCSVExport: function () 35 { 36 var gridPanel = this.up("gridpanel"); 37 var exporter = Ext.create("PartKeepr.Exporter.GridExporter", gridPanel, "text/comma-separated-values", "csv"); 38 exporter.exportGrid(); 39 }, 40 onExcelExport: function () 41 { 42 var gridPanel = this.up("gridpanel"); 43 var exporter = Ext.create("PartKeepr.Exporter.GridExporter", gridPanel, 44 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlsx"); 45 exporter.exportGrid(); 46 }, 47 onCustomExport: function () { 48 var j = Ext.create("Ext.window.Window", { 49 items: Ext.create("PartKeepr.Exporter.Exporter", { 50 model: this.up("gridpanel").getStore().getModel() 51 }), 52 title: i18n("Export"), 53 width: "80%", 54 height: "80%", 55 layout: 'fit', 56 maximizable: true, 57 closeAction: 'destroy' 58 59 }); 60 j.show(); 61 } 62 });