PageRenderTime 51ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/src/sap.ui.commons/test/sap/ui/commons/RowRepeater.html

https://gitlab.com/crsr/openui5
HTML | 275 lines | 239 code | 36 blank | 0 comment | 0 complexity | cb2fe76ca30dd0df96ab09effa91acd0 MD5 | raw file
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>RowRepeater - sap.ui.commons</title>
  7. <script id="sap-ui-bootstrap"
  8. data-sap-ui-theme="sap_goldreflection"
  9. data-sap-ui-trace="true"
  10. type="text/javascript"
  11. data-sap-ui-libs="sap.ui.commons"
  12. src="../../../../resources/sap-ui-core.js"
  13. >
  14. </script>
  15. <script type="text/javascript">
  16. // configuration matrix
  17. var configMatrix, configRow, configCell, configControl;
  18. configMatrix = new sap.ui.commons.layout.MatrixLayout("configMatrix");
  19. // property and aggregation switch row
  20. configRow = new sap.ui.commons.layout.MatrixLayoutRow();
  21. // render title
  22. configCell = new sap.ui.commons.layout.MatrixLayoutCell();
  23. configControl = new sap.ui.commons.CheckBox({text:"Render Title",checked:true,change:handleRenderTitle});
  24. configCell.addContent(configControl);
  25. configRow.addCell(configCell);
  26. // render filters
  27. configCell = new sap.ui.commons.layout.MatrixLayoutCell();
  28. configControl = new sap.ui.commons.CheckBox({text:"Render Filters",checked:true,change:handleRenderFilters});
  29. configCell.addContent(configControl);
  30. configRow.addCell(configCell);
  31. // render sorters
  32. configCell = new sap.ui.commons.layout.MatrixLayoutCell();
  33. configControl = new sap.ui.commons.CheckBox({text:"Render Sorters",checked:true,change:handleRenderSorters});
  34. configCell.addContent(configControl);
  35. configRow.addCell(configCell);
  36. // show more steps
  37. configCell = new sap.ui.commons.layout.MatrixLayoutCell();
  38. configControl = new sap.ui.commons.CheckBox({text:"Show More",checked:false,change:handleShowMore});
  39. configCell.addContent(configControl);
  40. configRow.addCell(configCell);
  41. // show more steps
  42. configCell = new sap.ui.commons.layout.MatrixLayoutCell();
  43. configControl = new sap.ui.commons.CheckBox({text:"Show Alerts",checked:false,change:handleShowAlerts});
  44. configCell.addContent(configControl);
  45. configRow.addCell(configCell);
  46. // trigger show more
  47. configCell = new sap.ui.commons.layout.MatrixLayoutCell();
  48. configControl = new sap.ui.commons.Button({text:"Trigger Show More",press:function(){oRowRepeater.triggerShowMore()}});
  49. configCell.addContent(configControl);
  50. configRow.addCell(configCell);
  51. // apply 2nd filter
  52. configCell = new sap.ui.commons.layout.MatrixLayoutCell();
  53. configControl = new sap.ui.commons.Button({text:"Apply 2nd Filter",press:function(){oRowRepeater.applyFilter("second_filter")}});
  54. configCell.addContent(configControl);
  55. configRow.addCell(configCell);
  56. // trigger 2nd sort
  57. configCell = new sap.ui.commons.layout.MatrixLayoutCell();
  58. configControl = new sap.ui.commons.Button({text:"Trigger 2nd Sorter",press:function(){oRowRepeater.triggerSort("second_sorter")}});
  59. configCell.addContent(configControl);
  60. configRow.addCell(configCell);
  61. configMatrix.addRow(configRow);
  62. // add to page
  63. configMatrix.placeAt("config_target");
  64. //**********************************************************************************
  65. // row template
  66. var matrix, subMatrix, matrixRow, matrixSubRow, matrixCell, control;
  67. // main matrix
  68. matrix = new sap.ui.commons.layout.MatrixLayout("theMatrix");
  69. matrix.setWidth("70%");
  70. // main row
  71. matrixRow = new sap.ui.commons.layout.MatrixLayoutRow();
  72. //image
  73. control = new sap.ui.commons.Image();
  74. control.setHeight("60px");
  75. control.setWidth("50px");
  76. control.bindProperty("src","src");
  77. matrixCell = new sap.ui.commons.layout.MatrixLayoutCell();
  78. matrixCell.addContent(control);
  79. matrixRow.addCell(matrixCell);
  80. //label 1
  81. control = new sap.ui.commons.Label();
  82. control.bindProperty("text","lastName");
  83. matrixCell = new sap.ui.commons.layout.MatrixLayoutCell();
  84. matrixCell.addContent(control);
  85. matrixRow.addCell(matrixCell);
  86. //label 2
  87. control = new sap.ui.commons.Label();
  88. control.bindProperty("text","name");
  89. matrixCell = new sap.ui.commons.layout.MatrixLayoutCell();
  90. matrixCell.addContent(control);
  91. matrixRow.addCell(matrixCell);
  92. //label 3
  93. control = new sap.ui.commons.Label();
  94. control.bindProperty("text","country");
  95. matrixCell = new sap.ui.commons.layout.MatrixLayoutCell();
  96. matrixCell.addContent(control);
  97. matrixRow.addCell(matrixCell);
  98. //link
  99. control = new sap.ui.commons.Link();
  100. control.bindProperty("text","href");
  101. matrixCell = new sap.ui.commons.layout.MatrixLayoutCell();
  102. matrixCell.addContent(control);
  103. matrixRow.addCell(matrixCell);
  104. // add row to matrix
  105. matrix.addRow(matrixRow);
  106. // create test data
  107. var dataObject = { data : [
  108. {lastName: "Platte", name: "Rudolf", href: "http://www.sap.com", src: "images/persons/male_PlatteR.jpg", gender: "male" , country: "US"},
  109. {lastName: "Dwyer", name: "Nora", href: "http://www.sap.com", src: "images/persons/female_DwyerN.jpg", gender: "female" , country: "US"},
  110. {lastName: "Wallace", name: "Alex", href: "http://www.sap.com", src: "images/persons/male_WallaceA.jpg", gender: "male", country: "DE"},
  111. {lastName: "Wang", name: "Megan", href: "http://www.sap.com", src: "images/persons/female_WangM.jpg", gender: "female", country: "US"},
  112. {lastName: "Ingalls", name: "Barbara", href: "http://www.sap.com", src: "images/persons/female_IngallsB.jpg", gender: "female" , country: "US"},
  113. {lastName: "Wallace", name: "Bruno", href: "http://www.sap.com", src: "images/persons/male_WallaceA.jpg", gender: "male", country: "US"},
  114. {lastName: "Zar", name: "Lou", href: "http://www.sap.com", src: "images/persons/male_FieldJ.jpg", gender: "male", country: "DE"},
  115. {lastName: "Watson", name: "Mary", href: "http://www.sap.com", src: "images/persons/female_WatsonM.jpg", gender: "female", country: "US"},
  116. {lastName: "Spring", name: "Sally", href: "http://www.sap.com", src: "images/persons/female_SpringS.jpg", gender: "female", country: "US"},
  117. {lastName: "Schutt", name: "Doris", href: "http://www.sap.com", src: "images/persons/female_BaySu.jpg", gender: "female", country: "US"},
  118. {lastName: "Nicols", name: "John", href: "http://www.sap.com", src: "images/persons/male_NicolsJ.jpg", gender: "male", country: "FR"},
  119. {lastName: "Gains", name: "Viola", href: "http://www.sap.com", src: "images/persons/female_GainsV.jpg", gender: "female", country: "DE"},
  120. {lastName: "Bay", name: "Sue", href: "http://www.sap.com", src: "images/persons/female_BaySu.jpg", gender: "female", country: "FR"},
  121. {lastName: "Smith", name: "John", href: "http://www.sap.com", src: "images/persons/male_SmithJo.jpg", gender: "male", country: "CH"},
  122. {lastName: "Gordon", name: "Randy", href: "http://www.sap.com", src: "images/persons/male_GordonR.jpg", gender: "male", country: "DE"},
  123. {lastName: "Schulz", name: "Justin", href: "http://www.sap.com", src: "images/persons/male_SchulzJ.jpg", gender: "male", country: "DE"},
  124. {lastName: "Time", name: "Tino", href: "http://www.sap.com", src: "images/persons/male_KentC.jpg", gender: "male", country: "US"},
  125. {lastName: "East", name: "Jonathan", href: "http://www.sap.com", src: "images/persons/male_EastJ.jpg", gender: "male", country: "FR"},
  126. {lastName: "Poole", name: "Gene", href: "http://www.sap.com", src: "images/persons/female.jpg", gender: "female", country: "IT"},
  127. {lastName: "Ander", name: "Corey", href: "http://www.sap.com", src: "images/persons/male_SchulzJ.jpg", gender: "male", country: "CH"},
  128. {lastName: "Early", name: "Brighton", href: "http://www.sap.com", src: "images/persons/i2.jpg", gender: "male", country: "FR"},
  129. {lastName: "Noring", name: "Constance", href: "http://www.sap.com", src: "images/persons/female_WatsonM.jpg", gender: "female", country: "US"},
  130. {lastName: "Miller", name: "Michael", href: "http://www.sap.com", src: "images/persons/male_MillerM.jpg", gender: "male", country: "DE"},
  131. {lastName: "Tress", name: "Matt", href: "http://www.sap.com", src: "images/persons/female.jpg", gender: "female", country: "US"},
  132. {lastName: "Turner", name: "Pamela", href: "http://www.sap.com", src: "images/persons/female_RushJ.jpg", gender: "female", country: "DE"},
  133. {lastName: "Dente", name: "Al", href: "http://www.sap.com", src: "images/persons/i2.jpg", gender: "male", country: "US"},
  134. {lastName: "Friese", name: "Andy", href: "http://www.sap.com", src: "images/persons/i3.jpg", gender: "male", country: "DE"},
  135. {lastName: "Mann", name: "Anita", href: "http://www.sap.com", src: "images/persons/i1.jpg", gender: "female", country: "DE"},
  136. {lastName: "Fisher", name: "Richard", href: "http://www.sap.com", src: "images/persons/male_FisherR.jpg", gender: "male", country: "US"},
  137. {lastName: "Fuchs", name: "Peter", href: "http://www.sap.com", src: "images/persons/male_FuchsP.jpg", gender: "male", country: "DE"},
  138. {lastName: "Rush", name: "Joanne", href: "http://www.sap.com", src: "images/persons/female_RushJ.jpg", gender: "female", country: "DE"},],
  139. empty : []
  140. };
  141. for(var n=1; n<=100; n++) {
  142. dataObject.data.push( { lastName:"LastName"+n, name:"Name"+n, src:"images/persons/male.jpg", country: "DE", href: "http://www.sap.com" } );
  143. }
  144. // create JSON model
  145. jQuery.sap.require("sap.ui.model.json.JSONModel");
  146. var oModel = new sap.ui.model.json.JSONModel();
  147. oModel.setData(dataObject);
  148. sap.ui.getCore().setModel(oModel);
  149. // create the row repeater control
  150. var oRowRepeater = new sap.ui.commons.RowRepeater("rr1",{currentPage:1});
  151. oRowRepeater.bindRows("/data",matrix);
  152. oRowRepeater.setNoData(new sap.ui.commons.TextView({text: "Sorry, no data available!"}));
  153. oRowRepeater.placeAt("rr1_target");
  154. //******************************************************************************************************
  155. // attach event listener
  156. oRowRepeater.attachFilter(displayEventInPopup);
  157. oRowRepeater.attachSort(displayEventInPopup);
  158. oRowRepeater.attachPage(displayEventInPopup);
  159. oRowRepeater.attachResize(displayEventInPopup);
  160. // title element for row repeater
  161. var oTitle = new sap.ui.core.Title({text:"Employees", icon:"images/SAPLogo.gif", tooltip:"Employees"});
  162. // filters array
  163. var aFilters = new Array();
  164. aFilters.push(new sap.ui.commons.RowRepeaterFilter("first_filter",{text:"All Countries"}));
  165. aFilters.push(new sap.ui.commons.RowRepeaterFilter("second_filter",{text:"Germany",filters:[new sap.ui.model.Filter("country","EQ", "DE")],tooltip:"Show Employees working in Germany"}));
  166. aFilters.push(new sap.ui.commons.RowRepeaterFilter("third_filter",{text:"USA",filters:[new sap.ui.model.Filter("country", "EQ","US")],tooltip:"Show Emloyees working in USA"}));
  167. // sorters array
  168. var aSorters = new Array();
  169. aSorters.push(new sap.ui.commons.RowRepeaterSorter("third_sorter",{text:"Country",sorter:new sap.ui.model.Sorter("country",true),tooltip:"Sort By Country"}));
  170. aSorters.push(new sap.ui.commons.RowRepeaterSorter("first_sorter",{text:"Gender",sorter:new sap.ui.model.Sorter("gender",false),tooltip:"Sort By Gender"}));
  171. aSorters.push(new sap.ui.commons.RowRepeaterSorter("second_sorter",{text:"Last Name",sorter:new sap.ui.model.Sorter("lastName",false)}));
  172. // call all aggregation and property functions
  173. handleRenderTitle(new sap.ui.base.Event("event_1",oRowRepeater,{checked:true}));
  174. handleRenderFilters(new sap.ui.base.Event("event_2",oRowRepeater,{checked:true}));
  175. handleRenderSorters(new sap.ui.base.Event("event_3",oRowRepeater,{checked:true}));
  176. handleShowMore(new sap.ui.base.Event("event_4",oRowRepeater,{checked:false}));
  177. // handle click on "render title" checkbox
  178. function handleRenderTitle(e) {
  179. if(e.getParameter("checked")) {
  180. oRowRepeater.setTitle(oTitle);
  181. } else {
  182. oRowRepeater.setTitle(null);
  183. }
  184. }
  185. // handle click on "render filters" checkbox
  186. function handleRenderFilters(e) {
  187. if(e.getParameter("checked")) {
  188. for(var n=0;n<aFilters.length;n++) {
  189. oRowRepeater.addFilter(aFilters[n]);
  190. }
  191. } else {
  192. oRowRepeater.removeAllFilters();
  193. }
  194. }
  195. // handle click on "render sorters" checkbox
  196. function handleRenderSorters(e) {
  197. if(e.getParameter("checked")) {
  198. for(var n=0;n<aSorters.length;n++) {
  199. oRowRepeater.addSorter(aSorters[n]);
  200. }
  201. } else {
  202. oRowRepeater.removeAllSorters();
  203. }
  204. }
  205. // handle click on "show more" checkbox
  206. function handleShowMore(e) {
  207. if(e.getParameter("checked")) {
  208. oRowRepeater.setShowMoreSteps(3);
  209. } else {
  210. oRowRepeater.setShowMoreSteps(0);
  211. }
  212. }
  213. // handle click on "show alerts" checkbox
  214. var bShowAlerts = false;
  215. function handleShowAlerts(e) {
  216. bShowAlerts = e.getParameter("checked");
  217. }
  218. // display an event summary popup if desired
  219. function displayEventInPopup(e) {
  220. if(!bShowAlerts) return;
  221. if(e.getId()=="filter") {
  222. alert( "Event: " + e.getId() + "\nID: " + e.getParameter("filterId") );
  223. } else if(e.getId()=="sort") {
  224. alert( "Event: " + e.getId() + "\nID: " + e.getParameter("sorterId") );
  225. } else if(e.getId()=="page") {
  226. alert( "Event: " + e.getId() + "\nCurrent Page: " + e.getParameter("currentPage") + "\nPrevious Page: " + e.getParameter("previousPage") );
  227. } else if(e.getId("showMore")) {
  228. alert( "Event: " + e.getId() + "\nNumber of Rows: " + e.getParameter("numberOfRows") + "\nPrevious Number of Rows: " + e.getParameter("previousNumberOfRows") );
  229. }
  230. }
  231. //**************************************************************************************************
  232. </script>
  233. </head>
  234. <body class="sapUiBody" role="application">
  235. <h1>Test Page for sap.ui.commons.RowRepeater</h1>
  236. <div id="config_target"></div>
  237. <div id="rr1_target"></div>
  238. </body>
  239. </html>