sapui5 - Add items to the sap.m.list using declarative support -
i want add items list using declaritive support. example:
this code. want put list element mark saysing:
// want insert elements here......
thanks
<!doctype html> <html> <head lang="en"> <meta charset="utf-8"> </head> <body> <script id='sap-ui-bootstrap' type='text/javascript' src='https://openui5.hana.ondemand.com/1.38.10/resources/sap-ui-core.js' data-sap-ui-libs="sap.ui.commons,sap.m" data-sap-ui-modules='sap.ui.core.declarativesupport' > </script> <div data-sap-ui-type='sap.m.listbase' > <div data-sap-ui-aggregation="content"> // want insert elements here...... </div> </div> <div data-sap-ui-type='sap.ui.ux3.navigationbar'> <div data-sap-ui-type="sap.ui.ux3.navigationitem" data-key="item1"data-text="item text 3"></div> <div data-sap-ui-type="sap.ui.ux3.navigationitem" data-key="item1" data-text="item text 3"></div> <div data-sap-ui-type="sap.ui.ux3.navigationitem" data-key="item1" data-text="item text 3"></div> </div> </div> </body> </html>
here 2 examples declaritive support (html tags omited).
the first shows navigationbar want:
<head> <script id="sap-ui-bootstrap" type="text/javascript" src="resources/sap-ui-core.js" data-sap-ui-xx-bindingsyntax="complex" data-sap-ui-modules="sap.ui.core.declarativesupport"> </script> <script> sap.ui.getcore().attachinit(function() { var navbar = sap.ui.core.declarativesupport.compile(document.getelementbyid("navbar")); }); </script> </head> <body class="sapuibody" id="content"> </body> <div id="navbar"> <div data-sap-ui-type="sap.ui.ux3.navigationbar"> <div data-sap-ui-type="sap.ui.ux3.navigationitem" data-key="item1"data-text="item text 3"></div> <div data-sap-ui-type="sap.ui.ux3.navigationitem" data-key="item1" data-text="item text 3"></div> <div data-sap-ui-type="sap.ui.ux3.navigationitem" data-key="item1" data-text="item text 3"></div> </div> </div>
the second 1 uses list standardlistitem , model binding:
<head> <script id="sap-ui-bootstrap" type="text/javascript" src="resources/sap-ui-core.js" data-sap-ui-xx-bindingsyntax="complex" data-sap-ui-modules="sap.ui.core.declarativesupport"> </script> <script> sap.ui.getcore().attachinit(function() { var list = sap.ui.core.declarativesupport.compile(document.getelementbyid("list")); sap.ui.getcore().setmodel(new sap.ui.model.json.jsonmodel({ "items" : [ { "name" : "test" }, { "name" : "declaritive support"}] }), "data"); }); </script> </head> <body class="sapuibody" id="content"> </body> <div id="list"> <div data-sap-ui-type="sap.m.list" data-items="{data>/items}"> <div data-sap-ui-aggregation="items"> <div data-sap-ui-type="sap.m.standardlistitem" data-title="{data>name}"></div> </div> </div> </div>
more details can found here. please note can't use listbase base implementation of list style controls, e.g. list or table. possible skip div defining aggregation ui5 has concept of default aggregation, items in case. can seen in first example well.
Comments
Post a Comment