Skip to Content

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

select first item in list issue

Hi All,

While i navigate from detail1  page to another master2-detail2 page , i have to select first record in master2 by default while laoding master2-detail2.

but it is not working and no error in console also.

below is my code for default selection.

in master2 controller and in onInit() method i have written code as below.

this.waitForInitialListLoading(function() {

  //On the empty hash select the first item

  this.selectFirstItem();

  });

waitForInitialListLoading: function(fnToExecute) {

  jQuery.when(this.oInitialLoadFinishedDeferred).then(jQuery.proxy(fnToExecute, this));

  },

selectFirstItem: function() {

  var oList = this.getView().byId("list2");

  var aItems = oList.getItems();

  if (aItems.length) {

  oList.setSelectedItem(aItems[0], true);

  }

  },

please help

Regards,

Vamsi

Former Member
replied

Hi,

  1.      var list = new sap.m.List({ 
  2.      id : "yourlist"
  3.      updateFinished : function(oEvent){  
  4.           var firstItem = this.getView().byId("yourlist").getItems()[0];  
  5.           this.getView().byId("yourlist").setSelectedItem(firstItem,true);  
  6.           // perform further neede code here..like modfieng detail page based upon first item 
  7.           } 
  8.      }); 

Try this

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