Skip to Content
0
May 10, 2016 at 07:26 AM

List only first 100 data getting displayed on growing (repeated service call)

2046 Views

Hi,

I have a service wherein I have implemented skip and top. Current total records ( more that 90000 ).

I do not want to load all the data at once.

So I am calling the service and passing the skip value as 0 and the top value as 100 and

when the update finished event is triggered, I am again incrementing the skip and top values by 100.

My view

<core:View xmlns:core="sap.ui.core" controllerName="root.modules.test.controller.Dialog" xmlns="sap.m">

<List id="dynList"

growing="true"

growingThreshold="99"

items="{/results}"

updateFinished = "oListupdateFinished"

updateStarted= "oListupdateStarted"

growingScrollToLoad="true"

growingTriggerText="More">

<StandardListItem description="{Description}" title="{Name}"/>

</List>

</core:View>

Controller

When the service is successfully called, I am getting the first 100 records, and then I am setting the data to the model.

While setting the data to the model, oListupdateStarted method is called and in oListupdateFinished method I am incrementing the top and skip values.

When I scroll down and click on More, that time I have 200 records, but only the first 99 or 100 records are getting displayed again.

But in the more I have got total records as 200 and incrementing by 100 every time.

loadData: function() {

// Here I am getting the data from the service

success: getDataSuccess ( on success)

},

getDataSuccess: function(data) {

var model;

var previousData = this.getView().getModel().getData();

for (var i = 0; i < data.results.length; i++) {

previousData.results.push(data.results[i]);

}

model = new sap.ui.model.json.JSONModel(previousData);

this.getView().setModel(model);

}

oListupdateFinished: function(oEvt) {

if (this.loadData === false) {

this.skip = this.top;

this.top = this.top + 100;

this.loadData = true;

}

},

oListupdateStarted: function(oEvt) {

if (this.loadData === true && oEvt.getParameter('reason')==="Growing") {

this.loadData();

}

}

Regards,

Gopa