sapui5 - Default Selected list item in Master view of the SplitApp -


i have 1 splitapp master -detail layout. know how can set first item in master view default on loading of application detail view shows information select list item. when user open application automatically first item in master should selected , detail view show information.

i using objectlist item control master view. , using select event selecting list item.

var olist = new sap.m.list("idmasterlist",{      mode: sap.m.listmode.singleselect,      select: [ocontroller.onselectitem, ocontroller]             }); 

onselectitem: function(oevent){

 //var app = sap.ui.getcore().byid("splitapp");  var omasterlist = sap.ui.getcore().byid("idmasterlist");  var oselitem = omasterlist.getselecteditem();   var spath = oselitem.obindingcontexts.druginfo.spath;   var oitem = sap.ui.getcore().getmodel("druginfo").getproperty(spath);  var oselmodel = new sap.ui.model.json.jsonmodel(oitem) ;  sap.ui.getcore().setmodel(oselmodel, "selecteditem");   } 

regards, mayank

it seems there (hidden) api make select event fire when setting selected item:

listbase.prototype.setselecteditem = function(olistitem, bselect, bfireevent) {     if (this.indexofitem(olistitem) < 0) {         jquery.sap.log.warning("setselecteditem called without valid listitem parameter on " + this);         return;     }     if (this._bselectionmode) {         olistitem.setselected((bselect === undefined) ? true : !!bselect);         bfireevent && this._fireselectionchangeevent([olistitem]);     } }; 

you use setselecteditem once lists data loaded (e.g. change event of aggregation binding items) this:

var olist = this.getview().byid("mylistid"),     ofirstitem = olist.getitems()[0]; olist.setselecteditem(ofirstitem, true, true); 

this trigger selectionchange resp. select event , existing event listener triggered.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -