cancel
Showing results for 
Search instead for 
Did you mean: 

How to bind text field value from selected row of sap.m.table values in same view

Former Member
0 Kudos

Hi,

Please share if there is any sample project/code to bind text field value from selected row of sap.m.table values in same view.

I was able to achieve this if text field is in different view by transferring context like this from controller.

handleListItemPress : function(evt) {

  var context = evt.getSource().getBindingContext();

  this.nav.to("Detail", context);

I am using single XML View and Controller .

I was able to read the data from selected row as well but unable to use it to set those values for other UI Elements.

Used below code to read selected row data.

onSelectionChange: function(oEvent){

  var oSelectedItem = oEvent.getParameter("listItem");

  var oSelectedItemContext = oSelectedItem.getBindingContext();

  var sTableMode = oSelectedItem._mode;

  var sId = oSelectedItem.getBindingContext().getProperty("id");

    var sName = oSelectedItem.getBindingContext().getProperty("Name");

    var age = oSelectedItem.getBindingContext().getProperty("Age");

    //sap.m.alert(sId);

     sap.m.MessageToast.show(sId+sName+age);

},

Regards,

Koti Reddy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I was able to use bind text fields/text using setTitle , setValue methods.Earlier I faced difficulty to set dynamic values of table selected row due to limitations to pass data between different layout controls.

Used below code from controller after modifying existing xml view under single layout control.

this.getView().byId("tf2").setValue(sId);

    this.getView().byId("tf3").setValue(sName);

    this.getView().byId("tf1").setValue(sId);

    this.getView().byId("pn2").setVisible(true);

    this.getView().byId("txtpn1").setText(sId);

    this.getView().byId("txtpn2").setText(sName);

Regards,

Koti Reddy

Answers (0)