Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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

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

Former Member
Former Member replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question