Posted 18 October 2020, 9:59 pm EST
Hello Jiri,
Sorry for the delayed response.
I was able to understand your issue and it seems that the moveElement will work for you in this scenario because if you will move the item using the CollectionView then you will have to call the refresh method (which I don’t think you want to). Otherwise, the items will not be updated.
Now, for the _idxData issue, I have forwarded a bug report to the developers regarding this with internal tracking id 467403. I will update you once I will hear from them.
The _idxData is private property and we can get its value by using the dataIndex property which is publicly accessible. So, as a workaround for this issue, you can override the dataIndex property to get the correct index of the data. Please refer to the sample link below for reference:
https://stackblitz.com/edit/js-hrreq2
In this sample, when you will click on the Add New button, a new item will be added using the addNew method so that it is added to the itemsAdded array. Now, the moveElement method is used to move this new item to its proper position. You can use the dataIndex or dataItem property to get the data bound to the row. If you will commit the changes to the server, you will observe that the newly added item will be sent to the server as expected.
Note that the item will not be added to the server because the OData server used in this sample has not implemented any kind of editing but you can use the Network tab of the Browser to check that the correct query is sent to the server.
Let me know if this resolves your issue.
~regards