如何创建OData列表?

时间:2015-10-12 10:40:19

标签: android odata sapui5

我想创建一个OList,以便每当我点击它时,每个位置都会打开一个新的OList。此刻我有以下代码:

function readCustomerSuccessCallback(data, response) {

        var citems = [];
        for (var i = 0; i < data.results.length; i++) {
            var citem = new sap.m.StandardListItem(
                    {
                    type: "Active",
                    tap : readProducts(data.results[i].STATION_ID),
                    title: data.results[i].CUSTOMER_NAME,
                    description: data.results[i].STATION_ID
                    });
            citems.push(citem);
        }
        var oList = new sap.m.List({
            headerText : "Customers",
            setGrowingScrollToLoad: true,
            items : citems,
            press: function(e) {
            console.log(oList.getSelectedItems());
            }
        });
        oList.placeAt("content"); // place model onto UI
    }
    function readProducts(category) {
        console.log("read request started");
        startTime = new Date();

        if (!haveAppId()) {
        return;
        }

        sURL = myUrl;
        var oHeaders = {};
        oHeaders['Authorization'] = authStr;
        //oHeaders['X-SMP-APPCID'] = appCID;    //this header is provided by the logon plugin

        var request = {
            headers : oHeaders,
            requestUri : sURL,
            method : "GET"
            };
        OData.read(request, readProductsSuccessCallback, errorCallback);
    }

读取CustomerSuccesCAllback的函数会创建一个OList,如果我点击此列表中的某个字段,我希望显示一个新列表。第二步是函数readproducts负责。

使用此代码它不起作用。它告诉我的不是客户,而只是他们的细节。 有人有想法吗?

1 个答案:

答案 0 :(得分:0)

readCustomerSuccessCallback

的变化
    tap: function(e){
            readProducts(this.getDescription),
         }
 //this will stop invoking the function while defining your items