Skip to Content
Apr 25, 2018 at 01:30 PM

SAPUI5 Dynamic binding of data in an Upload Collection

2281 Views Last edit Apr 25, 2018 at 01:34 PM 2 rev

Hi experts,
I've got a funny issue and I can't get it working.

I've got a sap.ui.table.Table that is dynamically created with a JSON data binding. Everything goes well untill I need a button at every data row and when a user clicks on the button a dialog is opened with a Upload Collection with UploadCollectionItems dynamically bound to it. I tried several ways how to do it and I can't figure it out.

This is my code

oTable.addColumn(new sap.ui.table.Column({
    label: new sap.m.Label({text: ""}),
    template: new sap.m.Button({
     icon: "sap-icon://attachment",
     press: function(oEvent) {
      var oDialog = new sap.m.Dialog({
         title: "File manager",
         icon: "sap-icon://attachment",
         new sap.m.UploadCollection({
          items: {
             path: oEvent.getSource().getBindingContext().getPath() + "/documents",
             template: new sap.m.UploadCollectionItem({fileName: "{filename}"}),
             templateShareable: true

To explain:

oEvent.getSource().getBindingContext().getPath() + "/documents"

This is a path to the row, if I do something like this:

var oPath = oEvent.getSource().getBindingContext().getPath() + "/documents";
var oFiles = oModel.getProperty(oPath);

so the oFiles array contains the items where item.filename really exists

Am I missing something?

Thank you very much for any help!