javascript - Create buttons on run time in OpenUI5 -


i'm new sapui5/openui5, writing experimental small project want create button each item of list variable length.

the buttons must point same event, such must know button pressed, either parameter, element or similar way.

i couldn't find anywhere in documentation how show buttons in view based on list. couldn't find either way create them on run time in <flexbox> element.

any light or link me?

this doable.

//this common btn click handler var btnhandler = function(evt) {   var obtn = evt.getsource();   //now have access respective button   var customdata = obtn.getcustomdata()[0].getvalue();   sap.m.messagetoast.show("button clicked:" + customdata) };  var oflexbox = new sap.m.flexbox();  (var = 0; < 5; i++) {   var btn = new sap.m.button({     text: "button" + i,     press: btnhandler,     //add custom data here.. aggregation means can add many customdatas required.     customdata: new sap.ui.core.customdata({       key: "key",       value:     })   });   oflexbox.additem(btn); }  oflexbox.placeat('content'); 

working jsfiddle here


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -