Skip to Content
avatar image
Former Member

I want to fetch data from input list item (xml view, js controller)

I want to fetch data from input list item binded to a JSON Model but I can not, I have tried everything. if there is a work around or any other solution please let me know

1.png (23.2 kB)
2.png (11.7 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 14, 2017 at 06:47 PM
    // Get the binded property from the lists
    var myContexts = this.byId("createOrder--orderList").getBinding("items").getCurrentContexts();				
    var myBoundDataObjects = myContexts.map(function(context) {
         return context.getObject();
    });
    // edit a certain attribute from the model
    for (var i = 0; i < myBoundDataObjects.length; i++) {
         if (myBoundDataObjects[i].i_Category_ID === categoryID) {
             myBoundDataObjects[i].i_Quantity = parseInt(Qty, 10);
             break;
         }
    }
    // create a json model to use later from any controller
    var ordersModel = new JSONModel(myBoundDataObjects);	
    sap.ui.getCore().setModel(ordersModel, "ordersModel");

    Thanks to boghyon

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 14, 2017 at 06:56 AM

    Hi,

    Try binding some property to the value property of input and get it by model name.

    <Input placeholder="Price" value="{someProp}"  />

    // In Controller this.getView().getModel("MdlName").getProperty("/someProp");
    Add comment
    10|10000 characters needed characters exceeded