Guest User

Untitled

a guest
Nov 21st, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.11 KB | None | 0 0
  1. Dente Al
  2. Friese Andy
  3. Mann Anita
  4.  
  5. 1 Dente Al
  6. 2 Friese Andy
  7. 3 Mann Anita
  8.  
  9. <!DOCTYPE html >
  10. <html>
  11. <head>
  12. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  13. <meta charset="utf-8">
  14. </head>
  15. <script id="sap-ui-bootstrap"
  16. src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
  17. data-sap-ui-theme="sap_belize" data-sap-ui-libs="sap.m,sap.ui.layout,sap.ui.commons,sap.ui.table"
  18. data-sap-ui-compatVersion="edge" data-sap-ui-preload="async"
  19. data-sap-ui-resourceroots='{
  20. "sap.ui.demo.wt": "./"
  21. }'>
  22. </script>
  23. <script>
  24. sap.ui.getCore().attachInit(function() {
  25. //Define some sample data
  26. var aData = [
  27. {lastName: "Dente", name: "Al"},
  28. {lastName: "Friese", name: "Andy"},
  29. {lastName: "Mann", name: "Anita"},
  30. {lastName: "Schutt", name: "Doris"},
  31. {lastName: "Open", name: "Doris"},
  32. {lastName: "Dewit", name: "Kenya"}
  33. ];
  34.  
  35. //Create an instance of the table control
  36. var oTable2 = new sap.ui.table.Table({
  37. visibleRowCount: 7,
  38. firstVisibleRow: 3
  39. });
  40.  
  41. //Define the columns and the control templates to be used
  42. oTable2.addColumn(new sap.ui.table.Column({
  43. label: new sap.ui.commons.Label({text: "Last Name"}),
  44. template: new sap.ui.commons.TextView().bindProperty("text", "lastName"),
  45. width: "200px"
  46. }));
  47.  
  48. oTable2.addColumn(new sap.ui.table.Column({
  49. label: new sap.ui.commons.Label({text: "First Name"}),
  50. template: new sap.ui.commons.TextField().bindProperty("value", "name"),
  51. width: "200px"
  52. }));
  53.  
  54. //Create a model and bind the table rows to this model
  55. var oModel2 = new sap.ui.model.json.JSONModel();
  56. oModel2.setData({modelData: aData});
  57. oTable2.setModel(oModel2);
  58. oTable2.bindRows("/modelData");
  59. //Initially sort the table
  60. oTable2.sort(oTable2.getColumns()[0]);
  61. //Bring the table onto the UI
  62. oTable2.placeAt("content");
  63.  
  64. });
  65. </script>
  66. <body class="sapUiBody" id="content">
  67. </body>
  68. </html>
  69.  
  70. oTable2.addColumn(new sap.ui.table.Column({
  71. label: new sap.ui.commons.Label({text: "Index"}),
  72. template: new sap.ui.commons.TextView({
  73. text: "12"
  74. }),
  75. width: "200px"
  76. }));
  77.  
  78. for (var i = 0, len = oTable2.getRows().length; i < len; i++){
  79. var row = oTable2.getRows()[i];
  80. var firstControl = row.getCells()[0];
  81. firstControl.setText(row.getIndex()+1);
  82. };
  83.  
  84. sap.ui.getCore().attachInit(function() {
  85. //Define some sample data
  86. var aData = [
  87. {lastName: "Dente", name: "Al"},
  88. {lastName: "Friese", name: "Andy"},
  89. {lastName: "Mann", name: "Anita"},
  90. {lastName: "Schutt", name: "Doris"},
  91. {lastName: "Open", name: "Doris"},
  92. {lastName: "Dewit", name: "Kenya"}
  93. ];
  94.  
  95. //Create an instance of the table control
  96. var oTable2 = new sap.ui.table.Table({
  97. visibleRowCount: 7,
  98. firstVisibleRow: 3
  99. });
  100. oTable2.addColumn(new sap.ui.table.Column({
  101. label: new sap.ui.commons.Label({text: "Index"}),
  102. template: new sap.ui.commons.TextView().bindProperty("text", "rowIndex"),
  103. width: "200px"
  104. }));
  105. //Define the columns and the control templates to be used
  106. oTable2.addColumn(new sap.ui.table.Column({
  107. label: new sap.ui.commons.Label({text: "Last Name"}),
  108. template: new sap.ui.commons.TextView().bindProperty("text", "lastName"),
  109. width: "200px"
  110. }));
  111.  
  112. oTable2.addColumn(new sap.ui.table.Column({
  113. label: new sap.ui.commons.Label({text: "First Name"}),
  114.  
  115. template: new sap.ui.commons.TextField().bindProperty("value", "name"),
  116. width: "200px"
  117. }));
  118. function fnAppenData(count,data, objName){
  119. return Array.apply(null, Array(count)).map(function(obj, i) {
  120. var obj = data[i];
  121. var name = data[i][objName];
  122. data[i][objName] = (i + 1) + " " + name;
  123. data[i]["rowIndex"] = (i + 1);
  124. var returndata = data[i];
  125. return returndata;
  126. //return {name: names[i % names.length] + i};
  127. });
  128. }
  129. //Create a model and bind the table rows to this model
  130. var oModel2 = new sap.ui.model.json.JSONModel(fnAppenData(aData.length, aData, "lastName"));
  131. oModel2.setData({modelData: aData});
  132. oTable2.setModel(oModel2);
  133. oTable2.bindRows("/modelData");
  134. //Initially sort the table
  135. oTable2.sort(oTable2.getColumns()[0]);
  136. //Bring the table onto the UI
  137. oTable2.placeAt("content");
  138.  
  139. });
  140.  
  141. <!DOCTYPE html >
  142. <html>
  143. <head>
  144. <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  145. <meta charset="utf-8"/>
  146. </head>
  147. <script id="sap-ui-bootstrap"
  148. src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
  149. data-sap-ui-theme="sap_belize" data-sap-ui-libs="sap.m,sap.ui.layout,sap.ui.commons,sap.ui.table"
  150. data-sap-ui-compatVersion="edge" data-sap-ui-preload="async"
  151. data-sap-ui-resourceroots='{
  152. "sap.ui.demo.wt": "./"
  153. }'>
  154. </script>
  155. <script>
  156. sap.ui.getCore().attachInit(function() {
  157. //Define some sample data
  158. var formatRowNumber = function(val) {
  159. if(!this.getBindingContext()) return null;
  160. var index = this.getBindingContext().getPath().split("/")[2];
  161. // (an example of path value here is "/modelData/0")
  162. return parseInt(index) + 1;
  163. };
  164.  
  165. var aData = [
  166. {lastName: "Dente", name: "Al"},
  167. {lastName: "Friese", name: "Andy"},
  168. {lastName: "Mann", name: "Anita"},
  169. {lastName: "Schutt", name: "Doris"},
  170. {lastName: "Open", name: "Doris"},
  171. {lastName: "Dewit", name: "Kenya"}
  172. ];
  173.  
  174. //Create an instance of the table control
  175. var oTable2 = new sap.ui.table.Table({
  176. visibleRowCount: 7,
  177. firstVisibleRow: 3
  178. });
  179.  
  180. //Define the columns and the control templates to be used
  181. oTable2.addColumn(new sap.ui.table.Column({
  182. label: new sap.ui.commons.Label({text: "Index"}),
  183. template: new sap.ui.commons.TextView().bindProperty("text", {path: '', formatter:formatRowNumber}),
  184. width: "200px"
  185. }));
  186.  
  187. oTable2.addColumn(new sap.ui.table.Column({
  188. label: new sap.ui.commons.Label({text: "Last Name"}),
  189. template: new sap.ui.commons.TextView().bindProperty("text", "lastName"),
  190. width: "200px"
  191. }));
  192.  
  193. oTable2.addColumn(new sap.ui.table.Column({
  194. label: new sap.ui.commons.Label({text: "First Name"}),
  195. template: new sap.ui.commons.TextField().bindProperty("value", "name"),
  196. width: "200px"
  197. }));
  198.  
  199. //Create a model and bind the table rows to this model
  200. var oModel2 = new sap.ui.model.json.JSONModel();
  201. oModel2.setData({modelData: aData});
  202. oTable2.setModel(oModel2);
  203. oTable2.bindRows("/modelData");
  204. //Initially sort the table
  205. oTable2.sort(oTable2.getColumns()[0]);
  206. //Bring the table onto the UI
  207. oTable2.placeAt("content");
  208.  
  209.  
  210. });
  211. </script>
  212. <body class="sapUiBody" id="content">
  213. </body>
  214. </html>
Add Comment
Please, Sign In to add comment