grid.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <!DOCTYPE html>
  2. <html lang="ko">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>1. Basic Example</title>
  6. <link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/nhnent/tui.grid/1.5.1/dist/grid.min.css" />
  7. <style>
  8. #grid {width: 600px; float:left; margin-right:20px;}
  9. #theme {width: 200px; float:left;}
  10. #custom-text {width: 300px; height:520px; font-size:12px;}
  11. h4 {margin: 5px 0;}
  12. .preset {margin-bottom:15px;}
  13. .custom p {margin: 5px 0}
  14. </style>
  15. </head>
  16. <body>
  17. <h1><a href="https://github.com/nhnent/tui.grid" target="_blank">TUI Grid</a></h1>
  18. <div class="code-html">
  19. <div id="grid"></div>
  20. <div id="theme">
  21. <div class="preset">
  22. <h4>Preset</h4>
  23. <button class="btn-theme" data-preset="default">default</button>
  24. <button class="btn-theme" data-preset="striped">striped</button>
  25. <button class="btn-theme" data-preset="clean">clean</button>
  26. </div>
  27. <div class="custom">
  28. <h4>Custom options</h4>
  29. <p><textarea id="custom-text">
  30. {
  31. grid: {
  32. background: '#fff',
  33. border: '#ccc',
  34. text: '#444'
  35. },
  36. selection: {
  37. background: '#4daaf9',
  38. border: '#004082'
  39. },
  40. toolbar: {
  41. border: '#ccc',
  42. background: '#fff'
  43. },
  44. scrollbar: {
  45. background: '#f5f5f5',
  46. thumb: '#d9d9d9',
  47. active: '#c1c1c1'
  48. },
  49. cell: {
  50. normal: {
  51. background: '#fbfbfb',
  52. border: '#e0e0e0'
  53. },
  54. head: {
  55. background: '#eee',
  56. border: '#ccc'
  57. },
  58. editable: {
  59. background: '#fbfbfb'
  60. },
  61. selectedHead: {
  62. background: '#d8d8d8'
  63. },
  64. focused: {
  65. border: '#418ed4'
  66. },
  67. disabled: {
  68. text: '#b0b0b0'
  69. },
  70. evenRow: {
  71. background: '#fbfbfb'
  72. },
  73. currentRow: {
  74. background: '#e0ffe0'
  75. }
  76. }
  77. }
  78. </textarea></p>
  79. <p><button class="btn-custom">Apply</button></p>
  80. </div>
  81. </div>
  82. </div>
  83. </body>
  84. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.js"></script>
  85. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script>
  86. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone.js"></script>
  87. <script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.code-snippet/1.2.0/code-snippet.js"></script>
  88. <script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.component.pagination/1.0.3/pagination.js"></script>
  89. <script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.grid/1.5.1/dist/grid.min.js"></script>
  90. <script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.grid/1.5.1/examples/data/grid-row-2000.js"></script>
  91. <script type="text/javascript" class="code-js">
  92. var grid = new tui.Grid({
  93. el: $('#grid'),
  94. headerHeight: 40,
  95. displayRowCount: 15,
  96. minimumColumnWidth: 100,
  97. rowHeight: 35,
  98. columnModelList: [
  99. {
  100. columnName: '_button',
  101. width: 30
  102. },
  103. {
  104. title: 'ID',
  105. columnName: 'c1',
  106. align: 'center',
  107. editOption: {
  108. beforeContent: 'FE',
  109. type: 'text'
  110. }
  111. },
  112. {
  113. title: 'Name',
  114. defaultValue: 2,
  115. columnName: 'c2',
  116. align: 'center',
  117. editOption: {
  118. type: 'text',
  119. }
  120. },
  121. {
  122. title: 'Score',
  123. columnName: 'c3',
  124. align: 'center',
  125. editOption: {
  126. type: 'text',
  127. afterContent: ' Point',
  128. }
  129. }
  130. ]
  131. });
  132. var rowList = [];
  133. (function() {
  134. _.times(20, function(number) {
  135. rowList.push({
  136. c1: String(Math.random()).substring(2, 10),
  137. c3: Math.round(Math.random() * 10000)
  138. });
  139. })
  140. })();
  141. rowList[0].c2 = 'Mustafa Cosme';
  142. rowList[1].c2 = 'Gunnar Fausto';
  143. rowList[2].c2 = 'Junior Morgan';
  144. rowList[3].c2 = 'Tódor Ingo';
  145. rowList[4].c2 = 'Zezé Obadiah';
  146. rowList[5].c2 = 'Alfwin Damir';
  147. rowList[6].c2 = 'Feroz Fredrik';
  148. rowList[7].c2 = 'Archer Beniamino';
  149. rowList[8].c2 = 'Dado Shaul';
  150. rowList[9].c2 = 'Svetoslav Eder';
  151. rowList[10].c2 = 'Lauri Gligor';
  152. rowList[11].c2 = 'Ruben Bèr';
  153. rowList[12].c2 = 'Vicenç Hadrien';
  154. rowList[13].c2 = 'Borna Rochus';
  155. rowList[14].c2 = 'Kristijonas Tate';
  156. rowList[15].c2 = 'Georg Ormazd';
  157. rowList[16].c2 = 'Kumara Archimedes';
  158. rowList[17].c2 = 'Hershel Radomil';
  159. rowList[18].c2 = 'Toma Levan';
  160. rowList[19].c2 = 'Njord Thoko';
  161. grid.setRowList(rowList);
  162. grid.disableRow(6);
  163. var currentPresetName = 'default';
  164. $('.btn-theme').click(function() {
  165. var preset = $(this).data('preset');
  166. currentPresetName = preset;
  167. tui.Grid.applyTheme(preset);
  168. });
  169. $('.btn-custom').click(function() {
  170. var options = eval('(' + $('#custom-text').val() + ')');
  171. tui.Grid.applyTheme(currentPresetName, options);
  172. });
  173. </script>
  174. </html>