I create an application with NDWS using sapui5 _javascript. I have a table in the view, which has some data (data is sync with database on server). I want to retrieve data from the table and export in into excel (so get separate excel doc). Here is my trigger:
var oExportToExcelButton = new sap.ui.commons.Button( {
text : "Export to Excel",
width : '120px',
style : sap.ui.commons.ButtonStyle.Emph,
press : function() {
var jsonDataObject = oController.model.getProperty("/matreqs");
var taskIdFromView = sap.ui.getCore().byId("taskId").getValue();
var jsonData = JSON.stringify(jsonDataObject);
$.ajax("api/wpi/processrequest/getexcelexportfile?taskId="
+ taskIdFromView, {
context : this,
type : "POST",
processData : false,
contentType : "application/json",
data : jsonData,
error : function(request, status, error) {
console.log(error);
},
success : function(data) {
oController.getRequestParameterValue();
console.log(data);
top.close();
}
});
}
});
getRequestParameterValue() is a function in controller:
getRequestParameterValue: function(name) {
var half = location.search.split("&" + name + "=")[1];
if (!half) half = location.search.split("?" + name + "=")[1];
return half ? decodeURIComponent(half.split("&")[0]) : null;
})
i am very new into programming, so i am sorry if my explanation is not very clear. any help is welcome!