03-29-2024 5:50 PM - edited 03-30-2024 2:48 PM
I have a button called EXPORT and now I need to create a shortcut to export file to excel. The short cut is Ctrl+Alt+E. When I press the shortcut it have to call the function "onCommandExecution" which will check the ID condition and execute the function "onExportToExcel". I have been made debugging an I the ID was not called in the function. In other words the function onCommandExecution has not been called. The problem have to be either in view file or in manifest file but I see that both are correct!
The problem is when I press the combination I do not get all of ctrl+alt+e. I get one of them in debugging.
Does someone have a solution please?
Thank you
//Controller.js file
onCommandExecution: function(oEvent) {
var mSId = oEvent.getSource().getId();
if (mSId === "CE_EXPORT") {
this.onExportToExcel();
}
},
onExportToExcel: function() {
var oSettings, oSheet, aProducts;
var aCols = [];
aCols = this.createColumnConfig();
aProducts = this.byId("messageTable").getModel("oMessageModel").getProperty('/');
var oDate = new Date();
var regex = new RegExp(",", "g");
var aDateArr = oDate.toISOString().split("T")[0].split("-");
var sDate = aDateArr.join().replace(regex, "");
var aTimeArr = oDate.toISOString().split("T")[1].split(":");
var sSeconds = oDate.toISOString().split("T")[1].split(":")[2].split(".")[0];
var sTime = aTimeArr[0] + aTimeArr[1] + sSeconds;
oSettings = {
workbook: {
columns: aCols
},
dataSource: aProducts,
fileName: "export_" + sDate + sTime
};
oSheet = new Spreadsheet(oSettings);
oSheet.build()
.then(function() {
MessageToast.show(this.getOwnerComponent().getModel("i18n").getResourceBundle().getText("excelDownloadSuccessful"));
})
.finally(function() {
oSheet.destroy();
});
},
//view.xml file
<Page>
<footer>
<OverflowToolbar >
<Button icon="sap-icon://excel-attachment" text="{i18n>exportToExcelBtn}" press="onExportToExcel" tooltip="{i18n>exportToExcelBtnTooltip}"/>
</OverflowToolbar>
</footer>
<dependents>
<core:CommandExecution id="CE_EXPORT" command="Export" enabled="true" execute="onCommandExecution" />
</dependents>
//manifest.json file
"sap.ui5": {
"rootView": {
"viewName": "com.volkswagen.ifdb.cc.sa.view.Main",
"type": "XML"
},
"dependencies": {
"minUI5Version": "1.65.0",
"libs": {
"sap.m": {},
"sap.ui.comp": {},
"sap.ui.core": {},
"sap.ui.layout": {},
"sap.ushell": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"commands": {
"Export":{
"shortcut": "Ctrl+Alt+E"
}
},
User | Count |
---|---|
80 | |
10 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.