Skip to Content
0
Former Member
Nov 10, 2014 at 10:31 PM

BindAggregation - How to update a particular entry of the list and not the entire list?

446 Views

Hi,

I am using an OData model for a list of feed entries.

var oFeedList = new sap.m.List(this.createId("feedControl"), {

growing: true,

showNoData: false

});

oFeedList.bindAggregation('items', {

path: 'FeedEntries',

template: oFeedItemTemplate

});

Now, whenever I try to update one particular feed entry (not the entire list) all the aggregated elements are destroyed and recreated which makes a simple click very slow.

For example,

On clicking a "Like" option on a Feed, it should only change the text to "Unlike" and set it in model. But because all the feed entries are aggregated, it destroys and recreates all the entries (which shouldn't be the case as not all the feed entries have changed) and takes longer to process the request.

this.oLikeLink = new sap.m.Link({

press: function() {

var putBody = {Liked: !self.getLiked()};

var path = self.getBindingContextPath();

var oModel = self.getModel();

oModel.update(path, putBody, {

merge: true,

fnSuccess: function() { },

fnError: "showErrorMessage"

});

}

});

this.oLikeLink.bindProperty('text', {

path: 'Liked',

formatter: function(liked) {

var key = liked === true ? "unlike" : "like";

return key;

}

});

Is there any way to unbind this aggregation - update the model for only a particular feed entry and not destroy and recreate all the feed entries?

Thanks in advance!

Prachi