List with factory (xml fragment) doesn't have re-use capabilities
I am using a normal List control with factory on items nothing fancy. The issue is that if you check in network tab it calls this "CustomListItem.fragment.xml" for each cell. So it doesn't re-use the cell but creates new one each time.
On this page I could find how the dev team is using aggregate binding with factory but I think what they do is not consistent. First they use XML views and in the controller they create js controls. I want to be consistent and use xml for all view related coding.
In iOS and Android they have something like a re-use id so that it will not be fetched each time.
Overview.view.xml
<List id="masterList" mode="SingleSelectMaster"
growing="true" items="{path: '/', factory: '.createListItems'}" growingScrollToLoad="true" >
</List>
Overview.controller.js
createListItems: function(sId, oContext){
if(oContext.getObject().Group != null){
//individual
return new sap.ui.xmlfragment(sId, "example.view.fragments.GroupListItem", this);
}else{
return new sap.ui.xmlfragment(sId, "example.view.fragments.CustomListItem", this);
}
}
CustomListItem.fragment.xml //just customlistitem with controls
GroupListItem.fragment.xml //just customlistitem with controls
Hi kyakubi, Thank you for your message. Can you also share some more information whether the fragment request in the debugger network has the status 200 or status 340? Usually the browser should handle the caching of the files or the server should be configured to handle the file requests and use the cached file. It would also be nice if you could provide us a working example where the issue can be reproduced.
Thanks and regards, Jay Barbhaiya
i use this workaround to solve this problem
instantiate fragment
this.groupListItemFragment = new sap.ui.xmlfragment("example.view.fragments.GroupListItem", this);
and then use it
createListItems: function(sId, oContext) {
return this.groupListItemFragment.clone(sId)
}
Since there is no response from the author for more than 4 weeks I'm closing the ticket.