1
votes

I'm using the UploadCollection. There is a standard plus button in the top right corner in which the user can upload a new file. I want to add a text "Add new item" to this button.

The standard API documentation doesn't mention anything about this button. Fiori guidelines states that it is not recommended but my user still wants to show it.

Is there any way to make this possible?

The control is used like this:

<UploadCollection id = "uploadCollection"
                  multiple = "true"
                  class = "sapUiNoMargin"
                  noDataText = "{i18n>noDataText}"
                  noDataDescription = "{i18n>noDataDescription}"
                  items = "{
                    path: 'app>/attachments',
                    templateShareable: false
                  }"
                  change = "onChangeUploadCollection"
                  beforeUploadStarts = "onBeforeUploadStarts"
                  fileDeleted = "onPressFileDelete"
                  uploadUrl = "/sap/opu/odata/xxx"
                  fileType = "{app>/filetypes}"
                  uploadComplete = "onUploadComplete"
                  typeMissmatch = "onTypeMissmatch">    
</UploadCollection>
1

1 Answers

2
votes

It is possible to manipulate the button via the corresponding FileUploader. As it is not intended to do that, UploadCollection does not provide a public method to access the FileUploader instance. However you can use the method _getFilerUploader, which is marked as private, to achieve this.

To display the upload button's text just add the following line to your controllers onInit method:

this.byId('uploadCollection')._getFileUploader().setIconOnly(false)

To manipulate the button text you can use method setButtonText.