cancel
Showing results for 
Search instead for 
Did you mean: 

How to take ObjectAttribute value from view while click the ObjectListItem

former_member187227
Participant
0 Kudos

Hi All,

        I'm Working in SAPUI5 application there i'm using ObjectListItem to display the data. In that i add some Object attributes, while click the list item need to take the value from it. I tried some code, when i assign some value to the variable it shows the data, but i give the oData field means it won't show data.

Code Snippet:

omaster.view.js

var empno=new sap.m.ObjectAttribute("empno", {text:"EmployeeNumber"});

  var trpno=new sap.m.ObjectAttribute("trpno", {text:"{Tripnumber}"});

var sendlist=new sap.m.ObjectListItem("sendlist", {

  title:"{Nameown}",

  number:"{Used}",

  numberUnit:"{Days}",

  type : "Active",

  press:oController.Detail,

  attributes : [new sap.m.ObjectAttribute({

                               text : "{CurrNotice}"

                         }),empno,trpno

                    

                      ],     

});

omaster.controller.js

Detail:function(){

  var iempp=sap.ui.getCore().byId("empno").getText();

  var trpnop=sap.ui.getCore().byId("lab").getText();

alert(iempp);

alert(trpnop);

},

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Will this help?

JS Bin - Collaborative JavaScript Debugging

On click of the list you should do this.

Detail:function(evt){

console.log(evt.getSource().getAggregation("attributes")[0].getBindingContext().getProperty("Tripnumber"))

},

Tripnumber : property name of your model

former_member187227
Participant
0 Kudos

Hi indrajith patel,

       Thank you for your response it's work fine now..

Answers (1)

Answers (1)

saivellanki
Active Contributor
0 Kudos

Hi Vinoth,

Try like this -


var objectListItem = sap.ui.getCore().byId("sendlist");     //Get Hold of ObjectListItem

var objectAttributes = objectListItem.getAggregation("attributes");    //Get Object Attributes Array

objectAttributes[0].getText(); //CurrNotice

objectAttributes[1].getText(); //EmployeeNumber

Check sample: Plunker

Regards,

Sai Vellanki.

former_member187227
Participant
0 Kudos

Hi Sai Vellanki,

        Sorry yar, I tried your code but i shows empty data only