openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

List with factory (xml fragment) doesn't have re-use capabilities

Open kyakubi opened this issue 9 years ago • 3 comments

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

kyakubi avatar Sep 08 '17 11:09 kyakubi

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

jaybarbhaiya avatar Sep 12 '17 13:09 jaybarbhaiya

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)
}

idglv avatar Oct 09 '17 14:10 idglv

Since there is no response from the author for more than 4 weeks I'm closing the ticket.

Shtilianova avatar Feb 07 '18 08:02 Shtilianova