Вопрос

I am trying to bind two different ListItems in a list. One is StandardListItem and another one is DisplayListItem. I have a JSON Model which contains data. I have tried everything to bind data to these listitems but nothing is being displayed. Here is my code :

var oList = new sap.m.List("id_olist");
    var Sli = new sap.m.StandardListItem("id_sli",{
        title : "{myModel>/rootNode/name}"
    });
    var Sli1 = new sap.m.DisplayListItem("id_sli1",{
        label : "{myModel>/rootNode/srno}"
    });
    oList.addItem(oSli);
    oList.addItem(oSli1);

My JSON Model is :

var data = {
    "rootNode":[
            {"name":"abc","srno":"123"}
           ]
    };

    var oModel = new sap.ui.model.json.JSONModel();
    oModel.setData(data);
    sap.ui.getCore().setModel(oModel,"myModel");

Is it even possible? I need help.

Это было полезно?

Решение

There are two things not logically correct / missing:

  1. You haven't supplied a binding to your sap.m.List control, and
  2. You are trying to display a list with two list items to the single same object {"name":"abc","srno":"123"} which isn't correct (it should be two separate objects in your model)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top