dropdown.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8'>
  5. <title>Dropdown cell type - 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="Dropdown cell type">
  29. <meta property="og:description"
  30. content="This example shows the usage of the Dropdown feature.">
  31. <meta property="og:url" content="http://handsontable.com/demo/dropdown.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/dropdown.html">
  37. <!--
  38. Google Analytics for GitHub Page. Don't copy this to your project :)
  39. -->
  40. <script src="js/ga.js"></script>
  41. <script data-jsfiddle="common">
  42. function getCarData() {
  43. return [
  44. ["Nissan", 2009, "black", "black"],
  45. ["Nissan", 2006, "blue", "blue"],
  46. ["Chrysler", 2004, "yellow", "black"],
  47. ["Volvo", 2012, "white", "gray"]
  48. ];
  49. }
  50. </script>
  51. </head>
  52. <body>
  53. <div class="wrapper">
  54. <div class="wrapper-row">
  55. <div id="global-menu-clone">
  56. <h1><a href="../index.html">Handsontable</a></h1>
  57. </div>
  58. <div id="container">
  59. <div class="columnLayout">
  60. <div class="rowLayout">
  61. <div class="descLayout">
  62. <div class="pad" data-jsfiddle="example1">
  63. <h2>Dropdown cell type</h2>
  64. <p>This example shows the usage of the Dropdown feature.</p>
  65. <p>Dropdown is based on <a href="autocomplete.html">Autocomplete</a> cell type. All options used by <code>autocomplete</code>
  66. cell type apply to <code>dropdown</code> as well.</p>
  67. <p>Internally, cell <code>{type: "dropdown"}</code> is equivalent to cell <code>{type: "autocomplete", strict:
  68. true, filter: false}</code>.</p>
  69. <p>Therefore you can think of <code>dropdown</code> as a searchable <code>&lt;select&gt;</code>. </p>
  70. <div id="example1"></div>
  71. <p>
  72. <button name="dump" data-dump="#example1" data-instance="hot" title="Prints current data source to Firebug/Chrome Dev Tools">Dump
  73. data to console
  74. </button>
  75. </p>
  76. </div>
  77. </div>
  78. <div class="codeLayout">
  79. <div class="pad">
  80. <div class="jsFiddle">
  81. <button class="jsFiddleLink" data-runfiddle="example1">Edit in jsFiddle</button>
  82. </div>
  83. <script data-jsfiddle="example1">
  84. var container = document.getElementById('example1'),
  85. hot;
  86. hot = new Handsontable(container, {
  87. data: getCarData(),
  88. startRows: 7,
  89. startCols: 4,
  90. colHeaders: ['Car', 'Year', 'Chassis color', 'Bumper color'],
  91. columns: [
  92. {},
  93. {type: 'numeric'},
  94. {
  95. type: 'dropdown',
  96. source: ['yellow', 'red', 'orange', 'green', 'blue', 'gray', 'black', 'white']
  97. },
  98. {
  99. type: 'dropdown',
  100. source: ['yellow', 'red', 'orange', 'green', 'blue', 'gray', 'black', 'white']
  101. }
  102. ]
  103. });
  104. </script>
  105. </div>
  106. </div>
  107. </div>
  108. <div class="footer-text">
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. <div id="outside-links-wrapper"></div>
  115. </body>
  116. </html>