Skip to Content
0
Jun 29, 2015 at 08:49 AM

Bind oData service values into textview in openui5

73 Views

Hi All,

I have try to bind the odata service values into Textview. In my case, I am getting oData service values through AJAX Request like below

var testURL = "http://xyz.com:8010/abc/services/CLAIM_VIEW.xsodata/CLAIM_VIEWParameters(TRANS_ID_IN='46751992-SOACT2')/Results?$format=json";
  //Create Model for View transaction details
  var oTransdeModel = new sap.ui.model.json.JSONModel();
  jQuery.ajax({
        url: testURL,  
        dataType: "json",
        success: function(data, textStatus, jqXHR) { 
         
        oTransdeModel.setData({data: data.d.results});            
         
        },
        error: function(jqXHR, textStatus, errorThrown) {
           
        }
    });

and my textview is like below.(I am using textview inside the pop-up)

function openDialog(){
  //Transaction popup dialog
  var oDialog1 = new sap.ui.commons.Dialog();
  oDialog1.setTitle("Transaction Details");
  oDialog1.setWidth("65%");
  oDialog1.setHeight("65%");
  oDialog1.addStyleClass("popbg");

  //Create Matrix layout for popup contents
  var oMatrixhead = new sap.ui.commons.layout.MatrixLayout({layoutFixed: true, width: '400px', columns: 1,width:"auto"});

  var oLabelcriteria = new sap.ui.commons.Label("");
  oLabelcriteria.setText("Transaction Details");
  oLabelcriteria.setDesign(sap.ui.commons.LabelDesign.Bold);
  oLabelcriteria.setWidth('820px');
  oLabelcriteria.addStyleClass("pophead");
  oMatrixhead.createRow(oLabelcriteria);

  var oMatrixpopr1 = new sap.ui.commons.layout.MatrixLayout({layoutFixed: true, width: '300px', columns: 4,width:"auto"});
  //oMatrixpopr1.setWidths('150px', '230px','200px','150px');

  var transactionid = new sap.ui.commons.Label({
  text: 'Transaction id:',
  width:'250px'
  }); 
  var oTextview = new sap.ui.commons.TextView({
  text:"{TRANS_ID}"
  });
  oTextview.setModel(oTransdeModel);
  oTextview.bindElement("/data");
  //oTextview.setText("46751992-SOACT2");
  oTextview.setWidth("200px");
  transactionid.setLabelFor(oTextview);

My service url json output like attached screenshot.

I have check the ajax url from browser console. it's return success. But data is not bind into textview. My final output will be like the attached screenshot.Can some one help me to fix this? Any help would be greatly appreciated.

Attachments

Screenshot_2.png (6.1 kB)