contextmenucopypaste.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <!doctype html>
  2. <html xmlns="http://www.w3.org/1999/html">
  3. <head>
  4. <meta charset='utf-8'>
  5. <title>Copy/Paste in the Context Menu - 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="Copy/Paste from theContext Menu">
  29. <meta property="og:description"
  30. content="This page shows how to use and configure Context Menu's Copy and Paste features in Handsontable.">
  31. <meta property="og:url" content="http://handsontable.com/demo/contextmenucopypaste.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/contextmenucopypaste.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="default"></a>
  54. <h2>Copy/Paste in the Context Menu</h2>
  55. <p>This page shows how to use and configure the Context Menu's Copy and Paste features in Handsontable.</p>
  56. <p>Copy and Paste feature are available in Handsontable by default, but only as key shortcuts (<code>Ctrl (Cmd) + C</code> and <code>Ctrl (Cmd) + V</code> respectively).<br>
  57. This plugin makes them available also as a clickable options in the context menu. Unfortunately, due to the browser's security restrictions, Handsontable is forced to use a third-party flash-based library. We chose to use <a rel="nofollow" title="Zero Clipboard library" href="https://github.com/zeroclipboard/zeroclipboard">ZeroClipboard</a> - it adds a small invisible flash clip to your website, allowing the user to click on it, and thus save data to the clipboard.</p>
  58. <p>Please note, that our Copy/Paste Context Menu plugin requires some additional preparation:
  59. <ul>
  60. <li><code>ZeroClipboard.js</code> must be present on your server and included in your website's <code>script</code> tag.</li>
  61. <li><code>ZeroClipboard.swf</code> must also be present at your server</li>
  62. </ul>
  63. </p>
  64. <p>To configure Handsontable to use this plugin you need to add a <code>contextMenuCopyPaste</code> config item to your Hansontable instance.<br>
  65. It can be set to:
  66. <ul>
  67. <li><code>true</code> - if the <code>ZeroClipboard.swf</code> file is placed in the same directory as the <code>ZeroClipboard.js</code>, or</li>
  68. <li><code>{<br>
  69. <b style="padding-left: 20px;">swfPath</b>: [path to the swf file],<br>
  70. &nbsp;}</code></li>
  71. </ul>
  72. <br><br>
  73. </p>
  74. <div id="example1"></div>
  75. <p>
  76. <button name="dump" data-instance="hot1" data-dump="#example1" title="Prints current data source to Firebug/Chrome Dev Tools">Dump
  77. data to console
  78. </button>
  79. </p>
  80. </div>
  81. </div>
  82. <div class="codeLayout">
  83. <div class="pad">
  84. <div class="jsFiddle">
  85. <button class="jsFiddleLink" data-runfiddle="example1">Edit in jsFiddle</button>
  86. </div>
  87. <script data-jsfiddle="common">
  88. function getData() {
  89. return [
  90. ['', 'Kia', 'Nissan', 'Toyota', 'Honda'],
  91. ['2008', 10, 11, 12, 13],
  92. ['2009', 20, 11, 14, 13],
  93. ['2010', 30, 15, 12, 13]
  94. ];
  95. }
  96. </script>
  97. <script data-jsfiddle="example1">
  98. var container = document.getElementById('example1'),
  99. hot1;
  100. hot1 = new Handsontable(container, {
  101. data: getData(),
  102. startRows: 5,
  103. startCols: 5,
  104. minRows: 5,
  105. minCols: 5,
  106. maxRows: 10,
  107. maxCols: 10,
  108. rowHeaders: true,
  109. colHeaders: true,
  110. minSpareRows: 1,
  111. contextMenu: true,
  112. contextMenuCopyPaste: {
  113. swfPath: 'swf/ZeroClipboard.swf'
  114. }
  115. });
  116. </script>
  117. </div>
  118. </div>
  119. </div>
  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>