on 10-16-2018 10:06 AM
Hello All,
I am using below link as an example,
https://sapui5.netweaver.ondemand.com/sdk/#/sample/sap.uxap.sample.ObjectPageFormLayout/preview
The input field is available in Simple form,
So When user give some value,How can I pass Value of Input field to my controller , so that I can send it Backend?
Thanks in advance.
Hi Sujoy,
Oh i get it now :).
Try this:
var sValue = this.getView().byId(this.getView().byId(<blockid>).getAssociation("selectedView") + "--" + <your control id>).getValue();
in my case the control id is "Input" and block id is jobinfo
var sValue = this.getView().byId(this.getView().byId("jobinfo").getAssociation("selectedView") + "--" + Input).getValue();
In the example you shared Block ID is available in ObjectPageFormLayout.view.xml
The cleaner way of doing this is by using models.
check this example, much better: https://sapui5.netweaver.ondemand.com/sdk/#/sample/sap.uxap.sample.ObjectPageFormLayout/preview
Hope it helps.
Regards,
Vinod
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello vinodkannappa,
I have one Question regarding how to trigger controller here,
https://sapui5.hana.ondemand.com/#/sample/sap.uxap.sample.ObjectPageFormLayout/preview
Suppose
<Input value=" " maxLength="8" width="200px" showValueHelp="true" valueHelpRequest="onSearch/>
So how to trigger onSearch event in controller?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You missed double quotes: try this.
var sValue = this.getView().byId(this.getView().byId("jobinfo").getAssociation("selectedView") + "--" + "STREETADDRESS1").getValue();
Regards,
Vinod
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can do it multiple ways:
Assign an id to your input control in the view and you can read the value in your controller as below:
In View:
<Input id="yourControlID" ......></Input>
Controller Code:
this.getView().byId("<yourControlID>").getValue();
Check documentation: https://sapui5.netweaver.ondemand.com/sdk/#/api/sap.m.Input/methods/getValue
You can also try binding a model to your simple form and bind a property to your input field.
As and when you enter the value in the input field, you model is updated and you can read the data by accessing the model in your controller.
Example with JSON Model: https://sapui5.hana.ondemand.com/#/sample/sap.m.tutorial.walkthrough.07/code (use getData method to read model data).
I quickly checked the example you are referring to, there is no model being used.
Regards,
Vinod
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Vinod,
Thanks for the reply,
I have already tried this.
In View:<Inputid="yourControlID" ......></Input>
Controller Code:
this.getView().byId("<yourControlID>").getValue();
Problem is - Input field is another view and it is Simple form.(It is not part of Main view)
So When Save button is press, onSave action is triggered in Controller
this.getView().byId("<yourControlID>").getValue(); is getting failed.
Any Idea How we can get that?
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.