stretch.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8'>
  5. <title>Column stretching - Handsontable</title>
  6. <!--
  7. Loading Handsontable (full distribution that includes all dependencies)
  8. -->
  9. <link data-jsfiddle="common" rel="stylesheet" media="screen" href="../dist/handsontable.css">
  10. <link data-jsfiddle="common" rel="stylesheet" media="screen" href="../dist/pikaday/pikaday.css">
  11. <script data-jsfiddle="common" src="../dist/pikaday/pikaday.js"></script>
  12. <script data-jsfiddle="common" src="../dist/moment/moment.js"></script>
  13. <script data-jsfiddle="common" src="../dist/zeroclipboard/ZeroClipboard.js"></script>
  14. <script data-jsfiddle="common" src="../dist/numbro/numbro.js"></script>
  15. <script data-jsfiddle="common" src="../dist/numbro/languages.js"></script>
  16. <script data-jsfiddle="common" src="../dist/handsontable.js"></script>
  17. <!--
  18. Loading demo dependencies. They are used here only to enhance the examples on this page
  19. -->
  20. <link data-jsfiddle="common" rel="stylesheet" media="screen" href="css/samples.css?20140331">
  21. <script src="js/samples.js"></script>
  22. <script src="js/highlight/highlight.pack.js"></script>
  23. <link rel="stylesheet" media="screen" href="js/highlight/styles/github.css">
  24. <link rel="stylesheet" href="css/font-awesome/css/font-awesome.min.css">
  25. <!--
  26. Facebook open graph. Don't copy this to your project :)
  27. -->
  28. <meta property="og:title" content="Column stretching">
  29. <meta property="og:description"
  30. content="This page shows how to configure Handsontable column stretching.">
  31. <meta property="og:url" content="http://handsontable.com/demo/stretch.html">
  32. <meta property="og:image" content="http://handsontable.com/demo/image/og-image.png">
  33. <meta property="og:image:type" content="image/png">
  34. <meta property="og:image:width" content="409">
  35. <meta property="og:image:height" content="164">
  36. <link rel="canonical" href="http://handsontable.com/demo/stretch.html">
  37. <!--
  38. Google Analytics for GitHub Page. Don't copy this to your project :)
  39. -->
  40. <script src="js/ga.js"></script>
  41. </head>
  42. <body>
  43. <div class="wrapper">
  44. <div class="wrapper-row">
  45. <div id="global-menu-clone">
  46. <h1><a href="../index.html">Handsontable</a></h1>
  47. </div>
  48. <div id="container">
  49. <div class="columnLayout">
  50. <div class="rowLayout">
  51. <div class="descLayout">
  52. <div class="pad">
  53. <h2>Column stretching</h2>
  54. <p>This page shows how to configure Handsontable column stretching:</p>
  55. <ul>
  56. <li><a href="#last">StretchH <code>last</code> column</a></li>
  57. <li><a href="#stretch">StretchH <code>all</code> columns</a></li>
  58. <li><a href="#none">StretchH <code>none</code> (default)</a></li>
  59. </ul>
  60. </div>
  61. </div>
  62. </div>
  63. <div class="rowLayout">
  64. <div class="descLayout">
  65. <div class="pad" data-jsfiddle="example2">
  66. <a name="last"></a>
  67. <h2>StretchH <code>last</code> column</h2>
  68. <p>The following example creates a table with vertical scrollbar by specifying
  69. only the container height and <code>overflow: hidden</code> in CSS.</p>
  70. <p>The last column is stretched using <code>stretchH: 'last'</code> option.</p>
  71. <div id="example2" style="height: 300px; overflow: hidden"></div>
  72. <p>
  73. <button name="dump" data-dump="#example2" data-instance="hot2" title="Prints current data source to Firebug/Chrome Dev Tools">Dump
  74. data to console
  75. </button>
  76. </p>
  77. </div>
  78. </div>
  79. <div class="codeLayout">
  80. <div class="pad">
  81. <div class="jsFiddle">
  82. <button class="jsFiddleLink" data-runfiddle="example2">Edit in jsFiddle</button>
  83. </div>
  84. <script data-jsfiddle="example2">
  85. /**
  86. * Container looks like this:
  87. *
  88. * <div id="example2" style="width: height: 300px; overflow: hidden"></div>
  89. */
  90. var container2 = document.getElementById('example2'),
  91. hot2;
  92. hot2 = new Handsontable(container2, {
  93. data: Handsontable.helper.createSpreadsheetData(40, 6),
  94. colWidths: [55, 47, 47, 47, 47, 47, 47], // can also be a number or a function
  95. rowHeaders: true,
  96. colHeaders: true,
  97. stretchH: 'last',
  98. minSpareRows: 1,
  99. contextMenu: true
  100. });
  101. </script>
  102. </div>
  103. </div>
  104. </div>
  105. <div class="rowLayout">
  106. <div class="descLayout">
  107. <div class="pad" data-jsfiddle="example3">
  108. <a name="stretch"></a>
  109. <h2>StretchH <code>all</code> columns</h2>
  110. <p>If the table content is not as wide as the container width, the table will be stretched to the container
  111. width. The default horizontal stretch model is to stretch the last column only (by using <code>stretchH:
  112. 'last'</code> option).</p>
  113. <p>Other possible stretch modes are <code>all</code> (stretches all columns equally, used in the below example)
  114. and <code>none</code> (not stretching).</p>
  115. <div id="example3" style="height: 300px; overflow: hidden;"></div>
  116. <p>
  117. <button name="dump" data-dump="#example3" data-instance="hot3" title="Prints current data source to Firebug/Chrome Dev Tools">Dump
  118. data to console
  119. </button>
  120. </p>
  121. </div>
  122. </div>
  123. <div class="codeLayout">
  124. <div class="pad">
  125. <div class="jsFiddle">
  126. <button class="jsFiddleLink" data-runfiddle="example3">Edit in jsFiddle</button>
  127. </div>
  128. <script data-jsfiddle="example3">
  129. /**
  130. * Container looks like this:
  131. *
  132. * <div id="example3" style="width: height: 300px; overflow: hidden"></div>
  133. */
  134. var container3 = document.getElementById('example3'),
  135. hot3;
  136. hot3 = new Handsontable(container3, {
  137. data: Handsontable.helper.createSpreadsheetData(40, 6),
  138. colWidths: [55, 47, 47, 47, 47, 47, 47], // can also be a number or a function
  139. rowHeaders: true,
  140. colHeaders: true,
  141. stretchH: 'all',
  142. minSpareRows: 1,
  143. contextMenu: true
  144. });
  145. </script>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="rowLayout">
  150. <div class="descLayout">
  151. <div class="pad" data-jsfiddle="example4">
  152. <a name="none"></a>
  153. <h2>StretchH <code>none</code> (default)</h2>
  154. <div id="example4" style="height: 300px; overflow: hidden"></div>
  155. <p>
  156. <button name="dump" data-dump="#example4" data-instance="hot4" title="Prints current data source to Firebug/Chrome Dev Tools">Dump
  157. data to console
  158. </button>
  159. </p>
  160. </div>
  161. </div>
  162. <div class="codeLayout">
  163. <div class="pad">
  164. <div class="jsFiddle">
  165. <button class="jsFiddleLink" data-runfiddle="example4">Edit in jsFiddle</button>
  166. </div>
  167. <script data-jsfiddle="example4">
  168. /**
  169. * Container looks like this:
  170. *
  171. * <div id="example4" style="width: height: 300px; overflow: hidden"></div>
  172. */
  173. var container4 = document.getElementById('example4'),
  174. hot4;
  175. hot4 = new Handsontable(container4, {
  176. data: Handsontable.helper.createSpreadsheetData(40, 6),
  177. colWidths: [55, 47, 47, 47, 47, 47, 47], // can also be a number or a function
  178. rowHeaders: true,
  179. colHeaders: true,
  180. stretchH: 'none', // actually you don't have to declare it because it is default
  181. minSpareRows: 1,
  182. contextMenu: true
  183. });
  184. </script>
  185. </div>
  186. </div>
  187. </div>
  188. <div class="footer-text">
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. <div id="outside-links-wrapper"></div>
  195. </body>
  196. </html>