cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos
482

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Prachi ,

I had the same problem with in one of my past project , but i was using Tables, not List i hope it will also work with List.


Solution which worked for me :

Do not update the Model ,somehow due to method Chaining/Bubbling it will give rise to rebinding which will recreate the entire list again .For this try to update the data copy and call refresh function.

-Ajay Nayak