column_resize.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8'>
  5. <title>Column &amp; row resize - Handsontable</title>
  6. <!--
  7. Loading Handsontable (full distribution that includes all dependencies apart from jQuery)
  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 resize">
  29. <meta property="og:description"
  30. content=".">
  31. <meta property="og:url" content="http://handsontable.com/demo/column_resize.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/column_resize.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" data-jsfiddle="example1">
  53. <a name="resize"></a>
  54. <h2>Column &amp; row resize</h2>
  55. <p>To enable these features, use settings <code>manualColumnResize: true</code> and <code>manualRowResize: true</code></p>
  56. <p>The draggable resize handle appears:</p>
  57. <ul>
  58. <li>in the right part of the column header,</li>
  59. <li>in the bottom part of the row header.</li>
  60. </ul>
  61. <p>Double click on the resize handle automatically adjusts size of the row or column.</p>
  62. <div class="state-loaded example1 alert">State of the table has been restored. <button class="mini reset-state1">Reset table state</button></div>
  63. <div id="example1" style="width: 400px; height: 300px; overflow: hidden;"></div>
  64. <p>
  65. <button name="dump" data-dump="#example1" data-instance="hot" title="Prints current data source to Firebug/Chrome Dev Tools">
  66. Dump
  67. data to console
  68. </button>
  69. </p>
  70. </div>
  71. </div>
  72. <div class="codeLayout">
  73. <div class="pad">
  74. <div class="jsFiddle">
  75. <button class="jsFiddleLink" data-runfiddle="example1">Edit in jsFiddle</button>
  76. </div>
  77. <script data-jsfiddle="example1">
  78. var container = document.getElementById('example1'),
  79. hot;
  80. hot = new Handsontable(container, {
  81. data: Handsontable.helper.createSpreadsheetData(1000, 10),
  82. rowHeaders: true,
  83. colHeaders: true,
  84. colWidths: [55, 80, 80, 80, 80, 80, 80],
  85. rowHeights: [50, 40, 100],
  86. manualColumnResize: true,
  87. manualRowResize: true,
  88. minSpareRows: 1,
  89. persistentState: true
  90. });
  91. </script>
  92. </div>
  93. </div>
  94. </div>
  95. <script type="text/javascript">
  96. (function(hot){
  97. var reset = document.querySelector('.reset-state1'),
  98. stateLoaded = document.querySelector('.state-loaded'),
  99. storedData = {},
  100. savedKeys;
  101. Handsontable.dom.addEvent(reset, 'click', function(){
  102. hot.runHooks('persistentStateReset');
  103. hot.updateSettings({
  104. manualColumnMove: true,
  105. manualRowMove: true,
  106. manualColumnResize: true,
  107. manualRowResize: true
  108. });
  109. stateLoaded.style.display = 'none';
  110. hot.render();
  111. });
  112. hot.runHooks('persistentStateLoad', '_persistentStateKeys', storedData);
  113. savedKeys = storedData.value;
  114. if (savedKeys && savedKeys.length > 0) {
  115. stateLoaded.style.display = 'block';
  116. hot.render();
  117. }
  118. })(hot);
  119. </script>
  120. <div class="footer-text">
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. <div id="outside-links-wrapper"></div>
  127. </body>
  128. </html>