add_row.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  5. <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/media/images/favicon.ico" />
  6. <title>DataTables example</title>
  7. <style type="text/css" title="currentStyle">
  8. @import "../../media/css/demo_page.css";
  9. @import "../../media/css/demo_table.css";
  10. </style>
  11. <script type="text/javascript" language="javascript" src="../../media/js/jquery.js"></script>
  12. <script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
  13. <script type="text/javascript" charset="utf-8">
  14. /* Global var for counter */
  15. var giCount = 1;
  16. $(document).ready(function() {
  17. $('#example').dataTable();
  18. } );
  19. function fnClickAddRow() {
  20. $('#example').dataTable().fnAddData( [
  21. giCount+".1",
  22. giCount+".2",
  23. giCount+".3",
  24. giCount+".4" ] );
  25. giCount++;
  26. }
  27. </script>
  28. </head>
  29. <body id="dt_example">
  30. <div id="container">
  31. <div class="full_width big">
  32. DataTables add row example
  33. </div>
  34. <h1>Preamble</h1>
  35. <p>DataTables adding rows in DataTables is done by assigning the DataTables jQuery object to a variable when initialising it, and then using it's API methods to add a new row. Deleting rows can be done in a similar manner.</p>
  36. <h1>Live example</h1>
  37. <p><a href="javascript:void(0);" onclick="fnClickAddRow();">Click to add a new row</a></p>
  38. <div id="demo">
  39. <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
  40. <thead>
  41. <tr>
  42. <th>Column 1</th>
  43. <th>Column 2</th>
  44. <th>Column 3</th>
  45. <th>Column 4</th>
  46. </tr>
  47. </thead>
  48. <tbody>
  49. <tr>
  50. <td>allan</td>
  51. <td>allan</td>
  52. <td>allan</td>
  53. <td>allan</td>
  54. </tr>
  55. </tbody>
  56. </table>
  57. </div>
  58. <div class="spacer"></div>
  59. <h1>Initialisation code</h1>
  60. <pre class="brush: js;">/* Global var for counter */
  61. var giCount = 1;
  62. $(document).ready(function() {
  63. $('#example').dataTable();
  64. } );
  65. function fnClickAddRow() {
  66. $('#example').dataTable().fnAddData( [
  67. giCount+".1",
  68. giCount+".2",
  69. giCount+".3",
  70. giCount+".4" ] );
  71. giCount++;
  72. }</pre>
  73. <style type="text/css">
  74. @import "../examples_support/syntax/css/shCore.css";
  75. </style>
  76. <script type="text/javascript" language="javascript" src="../examples_support/syntax/js/shCore.js"></script>
  77. <h1>Other examples</h1>
  78. <div class="demo_links">
  79. <h2>Basic initialisation</h2>
  80. <ul>
  81. <li><a href="../basic_init/zero_config.html">Zero configuration</a></li>
  82. <li><a href="../basic_init/filter_only.html">Feature enablement</a></li>
  83. <li><a href="../basic_init/table_sorting.html">Sorting data</a></li>
  84. <li><a href="../basic_init/multi_col_sort.html">Multi-column sorting</a></li>
  85. <li><a href="../basic_init/multiple_tables.html">Multiple tables</a></li>
  86. <li><a href="../basic_init/hidden_columns.html">Hidden columns</a></li>
  87. <li><a href="../basic_init/complex_header.html">Complex headers - grouping with colspan</a></li>
  88. <li><a href="../basic_init/dom.html">DOM positioning</a></li>
  89. <li><a href="../basic_init/flexible_width.html">Flexible table width</a></li>
  90. <li><a href="../basic_init/state_save.html">State saving</a></li>
  91. <li><a href="../basic_init/alt_pagination.html">Alternative pagination styles</a></li>
  92. <li>Scrolling: <br>
  93. <a href="../basic_init/scroll_x.html">Horizontal</a> /
  94. <a href="../basic_init/scroll_y.html">Vertical</a> /
  95. <a href="../basic_init/scroll_xy.html">Both</a> /
  96. <a href="../basic_init/scroll_y_theme.html">Themed</a> /
  97. <a href="../basic_init/scroll_y_infinite.html">Infinite</a>
  98. </li>
  99. <li><a href="../basic_init/language.html">Change language information (internationalisation)</a></li>
  100. <li><a href="../basic_init/themes.html">ThemeRoller themes (Smoothness)</a></li>
  101. </ul>
  102. <h2>Advanced initialisation</h2>
  103. <ul>
  104. <li>Events: <br>
  105. <a href="../advanced_init/events_live.html">Live events</a> /
  106. <a href="../advanced_init/events_pre_init.html">Pre-init</a> /
  107. <a href="../advanced_init/events_post_init.html">Post-init</a>
  108. </li>
  109. <li><a href="../advanced_init/column_render.html">Column rendering</a></li>
  110. <li><a href="../advanced_init/html_sort.html">Sorting without HTML tags</a></li>
  111. <li><a href="../advanced_init/dom_multiple_elements.html">Multiple table controls (sDom)</a></li>
  112. <li><a href="../advanced_init/length_menu.html">Defining length menu options</a></li>
  113. <li><a href="../advanced_init/complex_header.html">Complex headers and hidden columns</a></li>
  114. <li><a href="../advanced_init/dom_toolbar.html">Custom toolbar (element) around table</a></li>
  115. <li><a href="../advanced_init/highlight.html">Row highlighting with CSS</a></li>
  116. <li><a href="../advanced_init/row_grouping.html">Row grouping</a></li>
  117. <li><a href="../advanced_init/row_callback.html">Row callback</a></li>
  118. <li><a href="../advanced_init/footer_callback.html">Footer callback</a></li>
  119. <li><a href="../advanced_init/sorting_control.html">Control sorting direction of columns</a></li>
  120. <li><a href="../advanced_init/language_file.html">Change language information from a file (internationalisation)</a></li>
  121. <li><a href="../advanced_init/defaults.html">Setting defaults</a></li>
  122. <li><a href="../advanced_init/localstorage.html">State saving with localStorage</a></li>
  123. <li><a href="../advanced_init/dt_events.html">Custom events</a></li>
  124. </ul>
  125. <h2>API</h2>
  126. <ul>
  127. <li><a href="../api/add_row.html">Dynamically add a new row</a></li>
  128. <li><a href="../api/multi_filter.html">Individual column filtering (using "input" elements)</a></li>
  129. <li><a href="../api/multi_filter_select.html">Individual column filtering (using "select" elements)</a></li>
  130. <li><a href="../api/highlight.html">Highlight rows and columns</a></li>
  131. <li><a href="../api/row_details.html">Show and hide details about a particular record</a></li>
  132. <li><a href="../api/select_row.html">User selectable rows (multiple rows)</a></li>
  133. <li><a href="../api/select_single_row.html">User selectable rows (single row) and delete rows</a></li>
  134. <li><a href="../api/editable.html">Editable rows (with jEditable)</a></li>
  135. <li><a href="../api/form.html">Submit form with elements in table</a></li>
  136. <li><a href="../api/counter_column.html">Index column (static number column)</a></li>
  137. <li><a href="../api/show_hide.html">Show and hide columns dynamically</a></li>
  138. <li><a href="../api/api_in_init.html">API function use in initialisation object (callback)</a></li>
  139. <li><a href="../api/tabs_and_scrolling.html">DataTables scrolling and tabs</a></li>
  140. <li><a href="../api/regex.html">Regular expression filtering</a></li>
  141. </ul>
  142. </div>
  143. <div class="demo_links">
  144. <h2>Data sources</h2>
  145. <ul>
  146. <li><a href="../data_sources/dom.html">DOM</a></li>
  147. <li><a href="../data_sources/js_array.html">Javascript array</a></li>
  148. <li><a href="../data_sources/ajax.html">Ajax source</a></li>
  149. <li><a href="../data_sources/server_side.html">Server side processing</a></li>
  150. </ul>
  151. <h2>Server-side processing</h2>
  152. <ul>
  153. <li><a href="../server_side/server_side.html">Obtain server-side data</a></li>
  154. <li><a href="../server_side/custom_vars.html">Add extra HTTP variables</a></li>
  155. <li><a href="../server_side/post.html">Use HTTP POST</a></li>
  156. <li><a href="../server_side/ids.html">Automatic addition of IDs and classes to rows</a></li>
  157. <li><a href="../server_side/object_data.html">Reading table data from objects</a></li>
  158. <li><a href="../server_side/row_details.html">Show and hide details about a particular record</a></li>
  159. <li><a href="../server_side/select_rows.html">User selectable rows (multiple rows)</a></li>
  160. <li><a href="../server_side/jsonp.html">JSONP for a cross domain data source</a></li>
  161. <li><a href="../server_side/editable.html">jEditable integration with DataTables</a></li>
  162. <li><a href="../server_side/defer_loading.html">Deferred loading of Ajax data</a></li>
  163. <li><a href="../server_side/pipeline.html">Pipelining data (reduce Ajax calls for paging)</a></li>
  164. </ul>
  165. <h2>Ajax data source</h2>
  166. <ul>
  167. <li><a href="../ajax/ajax.html">Ajax sourced data (array of arrays)</a></li>
  168. <li><a href="../ajax/objects.html">Ajax sourced data (array of objects)</a></li>
  169. <li><a href="../ajax/defer_render.html">Deferred DOM creation for extra speed</a></li>
  170. <li><a href="../ajax/null_data_source.html">Empty data source columns</a></li>
  171. <li><a href="../ajax/custom_data_property.html">Use a data source other than aaData (the default)</a></li>
  172. <li><a href="../ajax/objects_subarrays.html">Read column data from sub-arrays</a></li>
  173. <li><a href="../ajax/deep.html">Read column data from deeply nested properties</a></li>
  174. </ul>
  175. <h2>Plug-ins</h2>
  176. <ul>
  177. <li><a href="../plug-ins/plugin_api.html">Add custom API functions</a></li>
  178. <li><a href="../plug-ins/sorting_plugin.html">Sorting and automatic type detection</a></li>
  179. <li><a href="../plug-ins/sorting_sType.html">Sorting without automatic type detection</a></li>
  180. <li><a href="../plug-ins/paging_plugin.html">Custom pagination controls</a></li>
  181. <li><a href="../plug-ins/range_filtering.html">Range filtering / custom filtering</a></li>
  182. <li><a href="../plug-ins/dom_sort.html">Live DOM sorting</a></li>
  183. <li><a href="../plug-ins/html_sort.html">Automatic HTML type detection</a></li>
  184. </ul>
  185. </div>
  186. <div id="footer" class="clear" style="text-align:center;">
  187. <p>
  188. Please refer to the <a href="http://www.datatables.net/usage">DataTables documentation</a> for full information about its API properties and methods.<br>
  189. Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and <a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of DataTables.
  190. </p>
  191. <span style="font-size:10px;">
  192. DataTables designed and created by <a href="http://www.sprymedia.co.uk">Allan Jardine</a> &copy; 2007-2011<br>
  193. DataTables is dual licensed under the <a href="http://www.datatables.net/license_gpl2">GPL v2 license</a> or a <a href="http://www.datatables.net/license_bsd">BSD (3-point) license</a>.
  194. </span>
  195. </div>
  196. </div>
  197. </body>
  198. </html>