on 2024 Oct 08 11:53 AM
Hi Experts!
I've implemented UploadSet and the files are getting uploaded as expected. But items are not getting refreshed after successful upload.
<upload:UploadSet id="uploadSet" instantUpload="false" uploadEnabled="true" afterItemAdded="onAfterItemAdded" uploadCompleted="onUploadCompleted" items="{filteredModel>/items}">
<upload:toolbar />
<upload:items>
<upload:UploadSetItem id="_IDGenUploadSetItem1" fileName="{filteredModel>fileName}" mediaType="{filteredModel>mediaType}" enabledEdit="false" visibleEdit="false" url="{filteredModel>url}" removePressed="onRemovePressed">
<upload:attributes>
<ObjectAttribute id="_IDGenObjectAttribute" title="Uploaded By" text="{filteredModel>createdBy}" active="false" />
<ObjectAttribute id="_IDGenObjectAttribute1" title="Uploaded on" text="{filteredModel>createdAt}" active="false" />
<ObjectAttribute id="_IDGenObjectAttribute2" title="File Size" text="{filteredModel>size}" active="false" />
</upload:attributes>
</upload:UploadSetItem>
</upload:items>
</upload:UploadSet>
Here I've used JSON model(filteredModel) because the forms entity has 1 to many relationship with the files entity. Hence I'm filtering out the data based on form_id.
If I refresh the whole page, I'm getting the expected output.
Best regards,
Adarsh
Request clarification before answering.
You could try two things, either:
Rebind the model
onUploadCompleted: function (oEvent) {
var oUploadSet = this.byId("uploadSet");
oUploadSet.removeAllIncompleteItems();
// Rebind the items to the model
oUploadSet.bindItems({
path: "filteredModel>/items",
template: oUploadSet.getBindingInfo("items").template
});
}
Or refresh the model a other way
onUploadCompleted: function (oEvent) {
var oUploadSet = this.byId("uploadSet");
oUploadSet.removeAllIncompleteItems();
// Refresh the filteredModel directly
var oModel = this.getView().getModel("filteredModel");
oModel.refresh(true); // Force update
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @adarsh-kmr ,
Try this,
onUploadCompleted: function (oEvent) {
this.getView().getModel("filteredModel").setProperty("/items",[]);
var oUploadSet = this.byId("uploadSet");
oUploadSet.removeAllIncompleteItems(true);
oUploadSet.removeAllItems(true);
},It will clear your upload set attachment which you added locally.
Regards,
Shubham
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 18 | |
| 7 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.