Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2015
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.71 KB | None | 0 0
  1. var mydata = {
  2. "bcListResponse": {
  3. "cardslist": [{
  4. "emails": [],
  5. "mobiles": [],
  6. "bcFirstName": "",
  7. "titles": [],
  8. "bcLastName": "",
  9. "businessCardId": 300
  10. }, {
  11. "emails": [{
  12. "email": "gregetbtr@crgtgb.fcefe"
  13. }, {
  14. "email": "dfewv@degbt.cgd"
  15. }],
  16. "mobiles": [{
  17. "mobile": "24154545454545"
  18. }, {
  19. "mobile": "205555555555"
  20. }],
  21. "bcFirstName": "aa",
  22. "titles": [{
  23. "company": "fefef",
  24. "title": "efe"
  25. }],
  26. "bcLastName": "bb",
  27. "businessCardId": 302
  28. }, {
  29. "emails": [],
  30. "mobiles": [{
  31. "mobile": "53643489"
  32. }],
  33. "bcFirstName": "ghfj",
  34. "titles": [],
  35. "bcLastName": "teyktuyklyi",
  36. "businessCardId": 303
  37. }, {
  38. "emails": [],
  39. "mobiles": [{
  40. "mobile": "jtykuyyukl"
  41. }],
  42. "bcFirstName": "hgyujg",
  43. "titles": [],
  44. "bcLastName": "ethryj",
  45. "businessCardId": 304
  46. }],
  47. "error": "",
  48. "status": "success"
  49. }
  50. };
  51.  
  52. <script id="templateData" type="text/x-jsrender">
  53. <tr>
  54. <td class="details">
  55. <table class="CardTable" cellpadding="3" cellspacing="2">
  56. <colgroup>
  57. <col width="50%">
  58. <col width="50%">
  59. </colgroup>
  60. <tbody>
  61. <tr>
  62. <td>{{:bcFirstName}} {{:bcLastName}} </td>
  63. </tr>
  64. </tbody>
  65. </table>
  66. </td>
  67. </tr>
  68. </script>
  69. <script type="text/javascript">
  70. $(function () {
  71. $("#Grid").ejGrid({
  72. // the datasource "window.employeeData" is referred from templatelocaldata.js
  73. dataSource: mydata,
  74. allowScrolling: true,
  75. scrollSettings: { height: 380, width: 500 },
  76. rowTemplate: "#templateData",
  77. columns: [
  78. { },
  79. { }
  80. ]
  81. });
  82. });
  83. </script>
  84.  
  85. var products={
  86. "bcListResponse": {
  87. "cardslist": [
  88. {
  89. "emails": [
  90.  
  91. ],
  92. "mobiles": [
  93.  
  94. ],
  95. "bcFirstName": "",
  96. "titles": [
  97.  
  98. ],
  99. "bcLastName": "",
  100. "businessCardId": 300
  101. },
  102. {
  103. "emails": [
  104. {
  105. "email": "gregetbtr@crgtgb.fcefe"
  106. },
  107. {
  108. "email": "dfewv@degbt.cgd"
  109. }
  110. ],
  111. "mobiles": [
  112. {
  113. "mobile": "24154545454545"
  114. },
  115. {
  116. "mobile": "205555555555"
  117. }
  118. ],
  119. "bcFirstName": "aa",
  120. "titles": [
  121. {
  122. "company": "fefef",
  123. "title": "efe"
  124. }
  125. ],
  126. "bcLastName": "bb",
  127. "businessCardId": 302
  128. },
  129. {
  130. "emails": [
  131.  
  132. ],
  133. "mobiles": [
  134. {
  135. "mobile": "53643489"
  136. }
  137. ],
  138. "bcFirstName": "ghfj",
  139. "titles": [
  140.  
  141. ],
  142. "bcLastName": "teyktuyklyi",
  143. "businessCardId": 303
  144. },
  145. {
  146. "emails": [
  147.  
  148. ],
  149. "mobiles": [
  150. {
  151. "mobile": "jtykuyyukl"
  152. }
  153. ],
  154. "bcFirstName": "hgyujg",
  155. "titles": [
  156.  
  157. ],
  158. "bcLastName": "ethryj",
  159. "businessCardId": 304
  160. }
  161. ],
  162. "error": "",
  163. "status": "success"
  164. }
  165. };
  166.  
  167.  
  168.  
  169.  
  170. // No template
  171. var i = 1;
  172. $(products.bcListResponse.cardslist).each(function() {
  173. debugger;
  174. var product = this;
  175. $("#output1").append("" + product.bcFirstName + " " + product.bcLastName + "");
  176. })
  177. //With a JsRender template
  178. $('#output2').html($('#myTmpl').render(products.bcListResponse.cardslist));
  179.  
  180. <table>
  181. <tr>
  182. <td class="details">
  183. <table class="CardTable" cellpadding="3" cellspacing="2">
  184. <colgroup>
  185. <col width="50%" />
  186. <col width="50%" />
  187. </colgroup>
  188. <tbody>
  189. <div id="output2">
  190. </div>
  191.  
  192. </tbody>
  193. </table>
  194. </td>
  195. </tr>
  196. </table>
  197. <hr />
  198.  
  199. <h3>With a template</h3>
  200. <div id="output1">
  201. </div>
  202.  
  203. <script id="myTmpl" type="text/x-jsrender">
  204. <tr>
  205. <td>{{:bcFirstName}} {{:bcLastName}} </td>
  206. </tr>
  207.  
  208. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement