on 08-11-2015 1:13 PM
Hi ,
I am trying to create form in SAPUI5 using sap.ui.layout.form.Form and am trying to reuse the code for generating same textfield many times. In order to do that I placed the code in a function in controller js file and When I am trying to pass a value from function in view js file to function in controller js file , it is not getting passed properly ie function is getting called but not the values.
Below is the code ,
//function in the controller js file
textField: function (labeltext,placeholder){
var formElement = new sap.ui.layout.form.FormElement({
label : new sap.ui.commons.Label({
text : this.labeltext // passed text from view js is not getting here
}),
fields : [ new sap.ui.commons.TextField({
required : true,
layoutData : new sap.ui.layout.form.GridElementData({
hCells : "3"
}),
placeholder : this.placeholder // passed text from view js is not getting here
}) ]
});
return formElement;
}
// function in the view js file
createContent : function(oController) {
var oLayout2 = new sap.ui.layout.form.GridLayout("L2");
var oForm2 = new sap.ui.layout.form.Form("F2", {
title : new sap.ui.core.Title({
text : "Employee Registration Form",
tooltip : "Register here"
}),
editable : true,
layout : oLayout2,
formContainers : [ new sap.ui.layout.form.FormContainer("C2", {
formElements : [
oController.textField("Employee Name","Please enter ur name"), // calling function textField here
]
}) ]
});
oForm2.placeAt("content");
}
output :
Please guide me in this.
Hi Venkatesh,
did you try without putting "this." before the variable?
Regards,
Georgi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Venkatesh,
Why are you passing the value as this.labeltext? it should be normal labeltext, same thing for place holder.
Try -
textField: function (labeltext,placeholder){
var formElement = new sap.ui.layout.form.FormElement({
label : new sap.ui.commons.Label({
text : labeltext // passed text from view js is not getting here
}),
fields : [ new sap.ui.commons.TextField({
required : true,
layoutData : new sap.ui.layout.form.GridElementData({
hCells : "3"
}),
placeholder : placeholder // passed text from view js is not getting here
}) ]
});
return formElement;
}
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.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
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.