cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting a row does not fetch data

Former Member
0 Kudos

Hi,

I followed this (http://scn.sap.com/community/developer-center/front-end/blog/2012/06/01/sample-application-using-ui5...) guide to create an SAPUI5 app getting data from the ECC server. We have gateway installed in our ECC system.

As per the document, when I select a user from the table, it should show the user's roles and profiles in different tabs. But when I select a user, I am not getting the roles or profiles - the table just says No data.

Here is the code I am using:

  //on select of record call the ODATA READ service and show more details about user. 
  userDetailsTable.attachRowSelect(function(oEvent) 
 
   var currentRowContext = oEvent.getParameter("rowContext"); 
   var selectedUserID = oModel.getProperty("username", currentRowContext); 
        
   //Here I am using datajs API to call the READ operation and setting the values to individual UI elements. 
OData.read("http://gatewaysrvr:8000/sap/opu/odata/sap/Z_USER_RFC_RIS/z_user_rfc_risCollection('"+selectedUserID+"')",  
   function (response)  
   {
   
     sap.ui.getCore().getControl("title_cb_m").setValue("Mr."); 
     sap.ui.getCore().getControl("firstname_tf_m").setValue(response.firstname); 
     sap.ui.getCore().getControl("lastname_tf_m").setValue(response.lastname); 
     sap.ui.getCore().getControl("language_tf_m").setValue(response.language); 
     sap.ui.getCore().getControl("department_tf_m").setValue(response.department); 
     sap.ui.getCore().getControl("telephone_tf_m").setValue(response.telephone); 
     sap.ui.getCore().getControl("e_mail_tf_m").setValue(response.e_mail); 
     sap.ui.getCore().getControl("country_cb_m").setValue(response.country); 
     sap.ui.getCore().getControl("city_tf_m").setValue(response.city); 
   }); 
 
   
      //userProfileDetailsTable.bindRows(currentRowContext+"/profiles_r");//(You can use the below syntax also) 
     userProfileDetailsTable.bindRows("/z_user_rfc_risCollection('"+selectedUserID+"')"+"/profiles_r"); 
   //The beauty is, you need not to map individual columns. Based on the value field mapping table column and fields in OData service it automatically maps the data.   
      //userRolesDetailsTable.bindRows(currentRowContext+"/activitygroups_r");//(You can use the below syntax also)  
    userRolesDetailsTable.bindRows("z_user_rfc_risCollection('"+selectedUserID+"')"+"/activitygroups_r"); 
  });

I am able to access this service from browser:

http://gatewaysrvr:8000/sap/opu/odata/sap/Z_USER_RFC_RIS/z_user_rfc_risCollection('RISHI')/activityg...

Please let me know how to get the data to a table when I select a particular row.

Thanks,

Rishi

Accepted Solutions (1)

Accepted Solutions (1)

GrahamRobbo
Active Contributor
0 Kudos

You are probably best to direct this to the OP of the blog.

Cheers

Graham Robbo

Former Member
0 Kudos

Hi Graham,

I am not exactly sure how to direct this specifically to Abhilash. I have posted this as a comment in the blog.

Thanks,

Rishi

Former Member
0 Kudos

Solved it...yay!!!

The model had to be set to the table, before binding it.

Used the below code:

   userProfileDetailsTable.setModel(oModel);
   userProfileDetailsTable.bindRows("/z_user_rfc_risCollection('"+selectedUserID+"')/profiles_r"); 

    userRolesDetailsTable.setModel(oModel);
   userRolesDetailsTable.bindRows("/z_user_rfc_risCollection('"+selectedUserID+"')"+"/activitygroups_r");

Answers (0)