on 08-21-2015 5:58 AM
I wanted to know how to fetch the data using getText function and to display the data on another page using setText function, I am confused, where to put the syntax of getText() and getText().
BTW, I am using a button to redirect from the first page to second.
I came accross this syntax, but I am not sure, if it is okay or not..
sap.ui.getCore().byId("inp").getText();
sap.ui.getCore().byId("inp").setText();
could anyone guide me through it???
Hi Sanjo,
First of all is it input control (or) label control? If it is input control, it doesn't have getText()/setText() methods. It has getValue()/setValue().
Fine to achieve your requirement, you can make use of model property.To do this, you should have a global json model defined.
In your first Page -
var oInputValue = "45" //Consider you have a input value
sap.ui.getCore().byId("oInput").setValue(oInputValue); //Value stored in oInput control
sap.ui.getCore().getModel().setProperty("/oInputValue", oInputValue); //Store the value in model
In your second Page -
var oInputValue = sap.ui.getCore().getModel().getProperty("/oInputValue"); //You will have the value here as 45
sap.ui.getCore().byId("oSecondInput").setValue(oInputValue); //second page input value will have the first page input value.
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sanjo,
It's better to use a model rather than passing parameters through view, since it will be useful anywhere in the application. Consider you have many views and you wanted to use the same value in third view, then you can just use this model path to bind the values.
Yes on button click, get all the input values and store it in a model array. So the same model can be used to bind the values in second view.
Use setProperty when you're setting any values and getProperty for getting the values.
Regards,
Sai Vellanki.
Hi Sanjo,
In component.js of your App, check this sample - Plunker
In above example - I used parameter passing, you can ignore that.
Regards,
Sai Vellanki.
var input = new sap.m.Input("inp",{
maxLength:20,
width:"30%",
})
var button = new sap.m.Button({
text: "Button",
press: function()
{
app.to(page1);
var oFieldValue1 = sap.ui.getCore().byId("inp").getValue();
sap.ui.getCore().byId("i4").setValue(oFieldValue1);
}
This works for me!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.