cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 issue?

vamsilakshman_pendurti
Active Participant
0 Kudos

Hi Experts,

I design one UI on Eclipse.Which displays one Form Control with 4 fields, these fields will be update based on Row Selection of a Table Control data.This table contains number of records and one toggle button on toolbar named as Change.The data will be changed when user pressed on Change Button. After changes has been done , that data was not reflects on FORM Control when user press on any row. Previous data only displays . you can check the below attached pic....

Could anybody look into this and give the solution...

Thanks,

Vamsi.

former_member340030
Contributor
0 Kudos

Code please ? .. might be you are not refreshing the binding of form control

thanks

Viplove

vamsilakshman_pendurti
Active Participant
0 Kudos

Hi vip,

Thanks for the reply...

how to refresh the Binding of Form Control..

give me syntax..

and here is my code for Change Button:

switchModel:function(oEvent){
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
/*debugger;*/
var selValue = oEvent.getParameter("pressed");
var oCore = sap.ui.getCore().byId("myTable");
var oModel = oCore.getModel();
/*debugger;*/
var oVamc = oCore.getModel("VAMC");
oCore.setModel(oModel,"VAMC");
oCore.setModel(oVamc);
},

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

For Row Selection:

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

rowSelect:function(oEvent){
debugger;
var oForm = new sap.ui.getCore().byId("myForm");
var oElement = {

path : oEvent.getParameter("rowContext").getPath()
};
/*debugger;*/
oForm.bindElement(oElement);
}

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Code In my VIEW :

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

var oModel = new sap.ui.model.json.JSONModel();

//oModel.setData(myData);
oModel.loadData("Model/oModel.json") ;

sap.ui.getCore().setModel(oModel);

var oModel1 = new sap.ui.model.json.JSONModel();
oModel1.loadData("Model/oModel1.json");
sap.ui.getCore().setModel(oModel1, "VAMC")



var oLbl1 = new sap.ui.commons.Label({text: "empNo"});
var oTxt1 = new sap.ui.commons.TextField({
width:"60px",
value:"{empNo}"
});

var oLbl2 = new sap.ui.commons.Label({text: "empName"});
var oTxt2 = new sap.ui.commons.TextField({width:"100px"});
oTxt2.bindValue("empName")

var oLbl3 = new sap.ui.commons.Label({text: "salary"});
var oTxt3 = new sap.ui.commons.TextField({width:"60px"});
oTxt3.bindProperty("value", "salary")

var oLbl4 = new sap.ui.commons.Label({text: "currency"});
var oTxt4 = new sap.ui.commons.TextField({
width:"40px",
value:{path:"currency"}
});


var sForm = new sap.ui.commons.form.SimpleForm("myForm", {

/*title : new sap.ui.core.Title({text:"Employee Data"}) ,*/
title : "Employee Information" ,
content: [

oLbl1 , oTxt1 ,
oLbl2 , oTxt2 ,
oLbl3 , oTxt3 ,
oLbl4 , oTxt4 ]
});

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

You can observe two JSON Models are there...

One is i called by default and another one is using name "VAMC"...

when we click on Change toolbar Button then the data is coming from "VAMC" named Json model Object .

Thanks,

Vamsi.

Joseph_BERTHE
Active Contributor
0 Kudos

Hello,

Please, do not code into your Views !!! don't forget the MVC paradigm !

By the way the Best practice is to use XML views. If you follow this, you will see it will become easier for you to code and debug your UI5 application.

Best regards,

Joseph

vamsilakshman_pendurti
Active Participant
0 Kudos

Thanks Joseph for your information...

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member484715
Contributor
0 Kudos

Find out the attachRowSelectionChange method.It is in the library sap.ui.table.

Regards,

vamsilakshman_pendurti
Active Participant
0 Kudos

Hi,

Thank you all for immediate reaction...

Issue has been resolved.

There is a mistake in my code itself...i.e.,

var oCore = sap.ui.getCore().byId("myTable");

the above line in my code is replaced with...

var oCore = sap.ui.getCore();

Now its working fine...

Thanks,

Vamsi.

Former Member
0 Kudos

Hi,

Why not simply update the model bound to form in Row Selection method.

Since by default model is two way, if you simply update Form model, it will be reflected in form also.

Rohit

former_member340030
Contributor
0 Kudos

Hi

Why you are using 'new' in row selection function ?

var oForm = new sap.ui.getCore().byId("myForm");

Thanks

Viplove