attachmentlistmodel updateAttachmentWithIndex behaviour

490
2
07-21-2020 11:29 PM
by Anonymous User
Not applicable

Using the QML api, I get an ArcGISFeature which has an 'attachments' property which is an 'AttachmentListModel' which I then display in a listivew. The attachments (images in this use case) all display fine. I then include a button in the delegate to rotate the image. My function rotates the image, then updates the attachment model like so:

feature.attachments.updateAttachment(.....)
or
feature.attachments.updateAttachmentWithIndex(.....)

This works.

However, in the process, the rotated attachment gets removed from the model and appended to the end of it. I'm wondering if this is expected behaviour or not? Both methods do this.

In particular, the method that is called "...withIndex" implied to me that it would update the attachment at that index in place.

If there are a number of attachments, this has the effect that, when the user clicks the rotate button, the attachment seems to disappear and confuses the user.

The AttachmentListModel doesn't seem to have methods to insert at a particular index, or reorder the list, so currently the only workaround I can see is to NOT use the AttachmentListModel directly but instead copy everything over to a standard listmodel which I'd rather not do.

Any suggestions?

cheers,

-Paul

0 Kudos
2 Replies
LucasDanzinger
Esri Frequent Contributor

Hey Paul -

I think for the time being, this is "as designed", though I can see where your workflow is causing confusion. I tested the same workflow on the REST page. For example:

- go to this feature Feature (ID: 3422124) 

- go to the attachment infos. note the top most attachment id

- go back to the feature page and go to update attachments

- pass in the attachment id and a new image

- go back to the attachment infos page and refresh - the updated attachment is now at the bottom

Couple of thoughts on where to go from here. First would be to log a bug - best place to do this would be with the server, so that all clients benefit from the change. As for workarounds in your code, I was wondering if you have autoFetchAttachments set to true on your attachment list model (it is by default). Perhaps you'd be better off setting it to false and then explicitly calling fetchAttachments when you want to get updates from the server.

0 Kudos
by Anonymous User
Not applicable

Good point about server, I'll try frame up a bug report (maybe more of a 'feature enhancement').

I forgot to mention that I was working with offline data, so interacting with a local geodatabase and the qml api only, although that doesn't change much I guess.

0 Kudos