on 01-08-2015 5:27 PM
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
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.