cancel
Showing results for 
Search instead for 
Did you mean: 

Kapsel Offline OData plugin issue when retrieving number of entries in a list

Former Member
0 Kudos

Hello everyone,

I'm developing a Cordova application with Kapsel and SAPUI5. using the new OData Offline plugin from Kapsel as the Offline storage.

I have sap.m.Text element where I want to show the number of entries from a list:


var productQuantity = new sap.m.Text();


I bind the value assigning a formatter:


productQuantity.bindText("idProduct", productCount);


And here's the formatter code, that returns the number of entries from the /Products list:


function productCount(oValue) {

        var oBindings = this.getModel().bindList("/Products");

        return oBindings.getLength();

}

Everyting works as intended when the device is online, the issue is when offline, the product list loads fine, but the counter always shows the number 10, which is not the same number of products in the list.

Is this count operation possible with the Offline OData plugin for Kapsel? Or there's another way?

Regards,

Kenyon Tu

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I was able to solve the problem by myself. Instead of using the "hack", described in the question, I replaced that with a simple odata count request:


var username = applicationContext.registrationContext.user;

var password = applicationContext.registrationContext.password;

var connectionId = applicationContext.applicationConnectionId;

var oHeaders = {};

oHeaders['Authorization'] = "Basic " + btoa(username + ":" + password);

oHeaders['X-SMP-APPCID'] = connectionId;

var request = {

    headers: oHeaders,

    requestUri: url,

    method: "POST"

};

var url = applicationContext.applicationEndpointURL + "/Products/$count";

var successCallback = function(data, response) {

  var count = parseInt(data);

  this.getView().byId("viewIdHere").setText(count);

}

OData.read(request, successCallback, errorCallback);

Thanks for the help!

Answers (1)

Answers (1)

Ali_Chalhoub
Advisor
Advisor
0 Kudos

Can you please sure with me all the steps so I can reproduce this. So here is what I would like:

1. The version and SP of the SMP server and SDK

2. The Offline oData configuration file if you imported one through eh Cockpit

3. What does the OData End point looks like?

4. What Mobile device OS you tested this with

5. If you can create a sample project that has this issue reproduced and share it, that would be great.

Thank you