on 04-21-2017 8:11 AM
In controller i have written a simple form. on click of a button this form will appear. I want to know how to take its value if i enter some data in the field without using id.
Any data from view to controller can be linked using data models. On binding, data typed on view will be instantly available in the models, which are accessible in controller.
Element iD is also another way to get the data entered by user in view.
SAP recommends usage of model binding to transfer data between views and controller.
Regards,
Sharath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi RAHEEN AFSHAN,
You need to use model for this to get any controls property value ..
If you don't want to use the id of the form than attach the model with a model name to the view or page which contains your simple form
var model = new sap.ui.model.json.JSONModel()
model.setData({SupplierName:'',HouseNumber:'',Street:'',ZIPCode:'',City:'',Country:''});
this.getView().setModel(model,"formModel");
this.getView().bindElement("formModel>/");
Now on Button press event you can get the data of the model attached
onPress:function(){
var data = this.getView().getModel("formModel").getData() // data contains the values you enter in the input fields above
}
thanks
Viplove
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Instead of getting values by element ID's we can get through model.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.