Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.