Created
April 13, 2017 06:47
-
-
Save AbhilashBiradar/5ca58be35aafde972cb0000723ffe8bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sap.ui.jsview("upload.upload", { | |
/** Specifies the Controller belonging to this View. | |
* In the case that it is not implemented, or that "null" is returned, this View does not have a Controller. | |
* @memberOf upload.upload | |
*/ | |
getControllerName : function() { | |
return "upload.upload"; | |
}, | |
/** Is initially called once after the Controller has been instantiated. It is the place where the UI is constructed. | |
* Since the Controller is given to this method, its event handlers can be attached right away. | |
* @memberOf upload.upload | |
*/ | |
createContent : function(oController) { | |
var oColumns = [ | |
new sap.m.Column({ | |
header : new sap.m.Label({text :"ID" }), | |
demandPopin : true, | |
hAlign : "Center", | |
visible : true | |
}), | |
new sap.m.Column({ | |
header : new sap.m.Label({text : "DESC"}), | |
demandPopin : true, | |
hAlign : "Center", | |
visible : true | |
}), | |
]; | |
var htmlUpload = new sap.ui.commons.FileUploader(/*"shopSchedulefileUploader",*/{ | |
width:"100%", | |
//buttonText:"Upload", | |
//buttonOnly:true, | |
placeholder:"Browse for file", | |
fileType: "csv", | |
uploadOnChange:false, | |
name: "uploadField", | |
change: function(e){ | |
var shoppingArr=[]; var status; | |
var reader = null; var arrayBuffer; var input; var upload = {}; | |
var file = /*sap.ui.getCore().byId("shopSchedulefileUploader").*/this.oFileUpload.files[0]; | |
if(file){ | |
Papa.parse(file, { | |
complete: function(results) { | |
var colLength = results.data[0].length; | |
var rowLength = results.data.length; | |
for(var j=1; j< rowLength; j++){ | |
var upload={}; | |
for(var i=0; i<colLength; i++){ | |
upload[results.data[0][i]]=results.data[j][i]; | |
} | |
shoppingArr.push(upload); | |
} | |
testModel.setData(shoppingArr); | |
testTable.setModel(testModel); | |
htmlUpload.setValue(""); | |
if(status=="success"){ | |
} | |
} | |
}); | |
} | |
}, | |
typeMissmatch: function (oEvent) { | |
var sName = oEvent.getParameter("fileName"); | |
var sType = oEvent.getParameter("fileType"); | |
var sMimeType = htmlUpload.getMimeType(); | |
if (!sMimeType) { | |
sMimeType = htmlUpload.getFileType(); | |
} | |
sap.ui.commons.MessageBox.show("File: " + sName + " is of type " + sType + " .Allowed types are: " + sMimeType + ".", "ERROR", "Wrong File type"); | |
}, | |
}); | |
var testTable = new sap.m.Table({ | |
growing: true, | |
growingScrollToLoad : true, | |
columns : oColumns | |
}); | |
var oTestTemplate = new sap.m.ColumnListItem({ | |
type : "Inactive", | |
unread : false, | |
cells : [ new sap.m.Text({ | |
text : "{GroupId}", | |
textAlign : sap.ui.core.TextAlign.Center | |
}), | |
new sap.m.Text({ | |
text : "{GroupDesc}", | |
textAlign : sap.ui.core.TextAlign.Center | |
}), | |
] | |
}); | |
testTable.bindItems('/',oTestTemplate,null,null ); | |
var testArr = []; | |
var testModel = new sap.ui.model.json.JSONModel(); | |
testModel.setData(testArr); | |
testTable.setModel(testModel); | |
return new sap.m.Page({ | |
title: "Upload-ABB", | |
content: [htmlUpload,testTable | |
] | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment