Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

XML Model Databinding Problem

Hello,

i get an Xml File through XML request which contains several ItemCodes.

After reading and assigning the data to the model i get at least 3 + entries.

var sXML =  oRequest_Item.responseText.substring(oRequest_Item.responseText.search("<GetProdSolutionsResult>"));

      sXML = sXML.substring(0, sXML.search("</GetProdSolutionsResult>"));

    

      

      oitem_Model.setXML(sXML);

            sap.ui.getCore().setModel(oitem_Model, "Item");

                    

            var test =oitem_Model.getProperty("/Solution/0/ItemCode" );

                     alert(test);

                      test = oitem_Model.getProperty("/Solution/1/ItemCode" );

                     alert(test);

                     test =oitem_Model.getProperty("/Solution/2/ItemCode" );

                     alert(test);

                     test =oitem_Model.getProperty("/Solution/3/ItemCode" );

                     alert(test);

My problem is i need to assign this model to an sap.m.Select

new sap.m.Select({

  editable : false,

  // selectedKey : "{SolutionCode}",

  items : {

  path :  "Item>/Solution/ItemCode",

  template : new sap.ui.core.Item(

  {

  text : "{Item>}",

  key :  "{Item>}"

  })

  },

   change : function(oEvent) {

   }

  }),  

If i do that i only get the first entry from the Itemcode in the Item model in the sap.m.Select listed. Not all itemcode entries that exist in the model.

Can someone tell me what in this binding is wrong?

Best regards

Dirk

Tags:
replied

Hi Dirk,


var oModel = new sap.ui.model.xml.XMLModel();

    oModel.loadData("your.xml", "", false);

    sap.ui.getCore().setModel(oModel, "Item");


// Model Structure Example

---Solution{ //Level 1

     ---ItemCode : [{ // Level 2

          "Mytext" : "1",

          "MyKey"  : "09"

}]

}


new sap.m.Select({

   editable : false,

   items : {

  path :  "Item>/Solution/ItemCode",

  template : new sap.ui.core.Item(

  {

  text : "{Item>Mytext}",

  key :  "{Item>MyKey}"

  })

  },

   change : function(oEvent) {

   }

    }), 

Could you please tell me what are the data/structure available in "Item" Model.

Run your Application---->Go to Console--->write sap.ui.getCore().getModel("Item"); -----> share with us

Thanks,

KA

  

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question