Skip to Content
0
Jul 15 at 10:30 AM

Fetch the data in Input field

81 Views

Hi Team,

I'm trying to populate the value in Input field. I have 1st input field and the button press and on press will populate the data in 2nd input field.

I'm using Northwind service URL: /V2/Northwind/Northwind.svc/

I have defined the odata in manisfest.json and used default model.

XML View:

<l:VerticalLayout width="100%" binding="{Customers}">

<Label text="Customers" labelFor="input1" />

<Input id="input1" value="{CustomerId}" />

<Button text="Button" type="Accept" press= "onPress1" icon = "sap-icon://accept"></Button>

<Label text="Company Name" labelFor="input2" />

<Input id = "input2" />

Controller:

onInit: function () {

var oModel = this.getOwnerComponent().getModel("myModel");

this.getView().setModel(oModel);

var FirstInput = this.getView().byId("input1").getValue();

oModel.read("/Customers/?" + "$filter = CustomerId eq + "FirstInput"", {

success:function(oChildEntry){ //do something },

error:function(oChildError){ //do something } }); },

onPress1: function (evt) {

MessageToast.show("show the value in input field "); this.getView().byId("input2").setValue("oChildEntry.CompanyName"); }

oModel.read is not reading the data properly here, Can you please look into this and tell me where I'm going wrong.