PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/vendor/plugins/datatables/extensions/Editor/examples/simple/join.html

https://gitlab.com/victor.flores/prueba
HTML | 385 lines | 344 code | 41 blank | 0 comment | 0 complexity | 7c450ffa1aabd06f81525bb9577090ec MD5 | raw file
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
  6. <meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
  7. <title>Editor example - Join tables - working with multiple SQL tables</title>
  8. <link rel="stylesheet" type="text/css" href="../../../../media/css/jquery.dataTables.css">
  9. <link rel="stylesheet" type="text/css" href="../../../TableTools/css/dataTables.tableTools.css">
  10. <link rel="stylesheet" type="text/css" href="../../css/dataTables.editor.css">
  11. <link rel="stylesheet" type="text/css" href="../../../../examples/resources/syntax/shCore.css">
  12. <link rel="stylesheet" type="text/css" href="../../../../examples/resources/demo.css">
  13. <style type="text/css" class="init">
  14. </style>
  15. <script type="text/javascript" language="javascript" src="../../../../media/js/jquery.js"></script>
  16. <script type="text/javascript" language="javascript" src="../../../../media/js/jquery.dataTables.js"></script>
  17. <script type="text/javascript" language="javascript" src="../../../TableTools/js/dataTables.tableTools.js"></script>
  18. <script type="text/javascript" language="javascript" src="../../js/dataTables.editor.js"></script>
  19. <script type="text/javascript" language="javascript" src="../../../../examples/resources/syntax/shCore.js"></script>
  20. <script type="text/javascript" language="javascript" src="../../../../examples/resources/demo.js"></script>
  21. <script type="text/javascript" language="javascript" src="../resources/editor-demo.js"></script>
  22. <script type="text/javascript" language="javascript" class="init">
  23. var editor; // use a global for the submit and return data rendering in the examples
  24. $(document).ready(function() {
  25. editor = new $.fn.dataTable.Editor( {
  26. ajax: "../php/join.php",
  27. table: "#example",
  28. fields: [ {
  29. label: "First name:",
  30. name: "users.first_name"
  31. }, {
  32. label: "Last name:",
  33. name: "users.last_name"
  34. }, {
  35. label: "Phone #:",
  36. name: "users.phone"
  37. }, {
  38. label: "Site:",
  39. name: "users.site",
  40. type: "select"
  41. }
  42. ]
  43. } );
  44. $('#example').dataTable( {
  45. dom: "Tfrtip",
  46. ajax: {
  47. url: "../php/join.php",
  48. type: 'POST'
  49. },
  50. columns: [
  51. { data: "users.first_name" },
  52. { data: "users.last_name" },
  53. { data: "users.phone" },
  54. { data: "sites.name" }
  55. ],
  56. tableTools: {
  57. sRowSelect: "os",
  58. aButtons: [
  59. { sExtends: "editor_create", editor: editor },
  60. { sExtends: "editor_edit", editor: editor },
  61. { sExtends: "editor_remove", editor: editor }
  62. ]
  63. },
  64. initComplete: function ( settings, json ) {
  65. // Populate the site select list with the data available in the
  66. // database on load
  67. editor.field( 'users.site' ).update( json.sites );
  68. }
  69. } );
  70. } );
  71. </script>
  72. </head>
  73. <body class="dt-example">
  74. <div class="container">
  75. <section>
  76. <h1>Editor example <span>Join tables - working with multiple SQL tables</span></h1>
  77. <div class="info">
  78. <p>Data in relational databases is often stored over multiple tables, partitioned by the data type and
  79. then joined together using SQL JOIN queries. Editor makes working with multiple tables super easy
  80. through its, and DataTables', ability to work with nested Javascript objects. Additional the PHP
  81. libraries <code>leftJoin()</code> method make working with joins on the server-side just as easy as on
  82. the client-side - see the <a href="//editor.datatables.net/manual/php/joins">PHP join documentation</a>
  83. for further information on the library options.</p>
  84. <p>This example shows the simplest, but also most common, use case for joined data - a foreign
  85. reference key, pointing to another record. In this case the <em>users</em> database table has a column
  86. called <em>site</em> which is a reference to the <em>sites</em> database table. Using the
  87. <code>leftJoin()</code> PHP method in Editor server-side classes, the returned data structure for each
  88. row looks like:</p>
  89. <pre>
  90. <code class="multiline language-js">{
  91. "DT_RowId": "row_1",
  92. "users": {
  93. "first_name": "Quynn",
  94. "last_name": "Contreras",
  95. "phone": "1-971-977-4681",
  96. "site": "1"
  97. },
  98. "sites": {
  99. "name": "Edinburgh"
  100. }
  101. }
  102. </code>
  103. </pre>
  104. <p>To display these fields in DataTables we use the <a href=
  105. "//datatables.net/reference/option/columns.data"><code class="option" title=
  106. "DataTables initialisation option">columns.data<span>DT</span></code></a> option to access the nested
  107. data - for example <code>users.first_name</code> (using dotted Javascript object notation).</p>
  108. <p>On create, edit and remove Editor will also update the database accordingly for these actions
  109. automatically. With Editor, editing joined tables takes seconds to configure saving you a huge amount
  110. of time.</p>
  111. </div>
  112. <table id="example" class="display" cellspacing="0" width="100%">
  113. <thead>
  114. <tr>
  115. <th>First name</th>
  116. <th>Last name</th>
  117. <th>Phone #</th>
  118. <th>Location</th>
  119. </tr>
  120. </thead>
  121. <tfoot>
  122. <tr>
  123. <th>First name</th>
  124. <th>Last name</th>
  125. <th>Phone #</th>
  126. <th>Location</th>
  127. </tr>
  128. </tfoot>
  129. </table>
  130. <ul class="tabs">
  131. <li class="active">Javascript</li>
  132. <li>HTML</li>
  133. <li>CSS</li>
  134. <li>Ajax</li>
  135. <li>Server-side script</li>
  136. </ul>
  137. <div class="tabs">
  138. <div class="js">
  139. <p>The Javascript shown below is used to initialise the table shown in this
  140. example:</p><code class="multiline brush: js;">var editor; // use a global for the submit and return data rendering in the examples
  141. $(document).ready(function() {
  142. editor = new $.fn.dataTable.Editor( {
  143. ajax: &quot;../php/join.php&quot;,
  144. table: &quot;#example&quot;,
  145. fields: [ {
  146. label: &quot;First name:&quot;,
  147. name: &quot;users.first_name&quot;
  148. }, {
  149. label: &quot;Last name:&quot;,
  150. name: &quot;users.last_name&quot;
  151. }, {
  152. label: &quot;Phone #:&quot;,
  153. name: &quot;users.phone&quot;
  154. }, {
  155. label: &quot;Site:&quot;,
  156. name: &quot;users.site&quot;,
  157. type: &quot;select&quot;
  158. }
  159. ]
  160. } );
  161. $('#example').dataTable( {
  162. dom: &quot;Tfrtip&quot;,
  163. ajax: {
  164. url: &quot;../php/join.php&quot;,
  165. type: 'POST'
  166. },
  167. columns: [
  168. { data: &quot;users.first_name&quot; },
  169. { data: &quot;users.last_name&quot; },
  170. { data: &quot;users.phone&quot; },
  171. { data: &quot;sites.name&quot; }
  172. ],
  173. tableTools: {
  174. sRowSelect: &quot;os&quot;,
  175. aButtons: [
  176. { sExtends: &quot;editor_create&quot;, editor: editor },
  177. { sExtends: &quot;editor_edit&quot;, editor: editor },
  178. { sExtends: &quot;editor_remove&quot;, editor: editor }
  179. ]
  180. },
  181. initComplete: function ( settings, json ) {
  182. // Populate the site select list with the data available in the
  183. // database on load
  184. editor.field( 'users.site' ).update( json.sites );
  185. }
  186. } );
  187. } );</code>
  188. <p>In addition to the above code, the following Javascript library files are loaded for use in this
  189. example:</p>
  190. <ul>
  191. <li><a href="../../../../media/js/jquery.js">../../../../media/js/jquery.js</a></li>
  192. <li><a href=
  193. "../../../../media/js/jquery.dataTables.js">../../../../media/js/jquery.dataTables.js</a></li>
  194. <li><a href=
  195. "../../../TableTools/js/dataTables.tableTools.js">../../../TableTools/js/dataTables.tableTools.js</a></li>
  196. <li><a href="../../js/dataTables.editor.js">../../js/dataTables.editor.js</a></li>
  197. </ul>
  198. </div>
  199. <div class="table">
  200. <p>The HTML shown below is the raw HTML table element, before it has been enhanced by
  201. DataTables:</p>
  202. </div>
  203. <div class="css">
  204. <div>
  205. <p>This example uses a little bit of additional CSS beyond what is loaded from the library
  206. files (below), in order to correctly display the table. The additional CSS used is shown
  207. below:</p><code class="multiline brush: js;"></code>
  208. </div>
  209. <p>The following CSS library files are loaded for use in this example to provide the styling of the
  210. table:</p>
  211. <ul>
  212. <li><a href=
  213. "../../../../media/css/jquery.dataTables.css">../../../../media/css/jquery.dataTables.css</a></li>
  214. <li><a href=
  215. "../../../TableTools/css/dataTables.tableTools.css">../../../TableTools/css/dataTables.tableTools.css</a></li>
  216. <li><a href="../../css/dataTables.editor.css">../../css/dataTables.editor.css</a></li>
  217. </ul>
  218. </div>
  219. <div class="ajax">
  220. <p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
  221. will update automatically as any additional data is loaded.</p>
  222. </div>
  223. <div class="php">
  224. <p>The script used to perform the server-side processing for this table is shown below. Please note
  225. that this is just an example script using PHP. Server-side processing scripts can be written in any
  226. language, using <a href="//datatables.net/manual/server-side">the protocol described in the
  227. DataTables documentation</a>.</p>
  228. </div>
  229. </div>
  230. </section>
  231. </div>
  232. <section>
  233. <div class="footer">
  234. <div class="gradient"></div>
  235. <div class="liner">
  236. <h2>Other examples</h2>
  237. <div class="toc">
  238. <div class="toc-group">
  239. <h3><a href="./index.html">Simple initialisation</a></h3>
  240. <ul class="toc active">
  241. <li><a href="./simple.html">Basic initialisation</a></li>
  242. <li><a href="./fieldDefaults.html">Setting defaults</a></li>
  243. <li><a href="./fieldTypes.html">Field types</a></li>
  244. <li><a href="./dates.html">Dates (with jQuery UI datepicker)</a></li>
  245. <li><a href="./i18n.html">Internationalisation</a></li>
  246. <li><a href="./inTableControls.html">In table form controls</a></li>
  247. <li><a href="./responsive.html">Responsive table extension</a></li>
  248. <li><a href="./server-side-processing.html">Server-side processing</a></li>
  249. <li class="active"><a href="./join.html">Join tables - working with multiple SQL
  250. tables</a></li>
  251. </ul>
  252. </div>
  253. <div class="toc-group">
  254. <h3><a href="../advanced/index.html">Advanced initialisation</a></h3>
  255. <ul class="toc">
  256. <li><a href="../advanced/formOnlyData.html">Data shown only in the form</a></li>
  257. <li><a href="../advanced/tableOnlyData.html">Data shown in table only</a></li>
  258. <li><a href="../advanced/deepObjects.html">Complex (nested) JSON data source</a></li>
  259. <li><a href="../advanced/REST.html">REST interface</a></li>
  260. <li><a href="../advanced/localstorage.html">Ajax override - using localStorage for the data
  261. source</a></li>
  262. <li><a href="../advanced/jsonId.html">Row ID source specification</a></li>
  263. <li><a href="../advanced/htmlTable.html">DOM sourced table</a></li>
  264. <li><a href="../advanced/exportButtons.html">Export buttons</a></li>
  265. <li><a href="../advanced/joinSelf.html">Join tables - self referencing join</a></li>
  266. <li><a href="../advanced/joinLinkTable.html">Join tables - link table</a></li>
  267. <li><a href="../advanced/joinArray.html">Join tables - one-to-many join</a></li>
  268. </ul>
  269. </div>
  270. <div class="toc-group">
  271. <h3><a href="../bubble-editing/index.html">Bubble editing</a></h3>
  272. <ul class="toc">
  273. <li><a href="../bubble-editing/simple.html">Simple bubble editing</a></li>
  274. <li><a href="../bubble-editing/grouped.html">Multiple fields in a bubble</a></li>
  275. <li><a href="../bubble-editing/options.html">Form control and display options</a></li>
  276. <li><a href="../bubble-editing/defaultOptions.html">Default control and display
  277. options</a></li>
  278. <li><a href="../bubble-editing/inTableControls.html">Bubble editing with in table row
  279. controls</a></li>
  280. </ul>
  281. </div>
  282. <div class="toc-group">
  283. <h3><a href="../inline-editing/index.html">Inline editing</a></h3>
  284. <ul class="toc">
  285. <li><a href="../inline-editing/simple.html">Simple inline editing</a></li>
  286. <li><a href="../inline-editing/tabControl.html">Tab between columns</a></li>
  287. <li><a href="../inline-editing/options.html">Editing options - submit on blur</a></li>
  288. <li><a href="../inline-editing/submitButton.html">Inline editing with a submit
  289. button</a></li>
  290. <li><a href="../inline-editing/editIcon.html">Edit icon</a></li>
  291. </ul>
  292. </div>
  293. <div class="toc-group">
  294. <h3><a href="../api/index.html">API</a></h3>
  295. <ul class="toc">
  296. <li><a href="../api/confirmClose.html">Events - unsaved changes close confirmation</a></li>
  297. <li><a href="../api/clientValidation.html">Client-side validation</a></li>
  298. <li><a href="../api/triggerButton.html">Customised control buttons</a></li>
  299. <li><a href="../api/backNext.html">Previous / next editing buttons</a></li>
  300. <li><a href="../api/duplicateButton.html">Duplicate button</a></li>
  301. </ul>
  302. </div>
  303. <div class="toc-group">
  304. <h3><a href="../standalone/index.html">Standalone</a></h3>
  305. <ul class="toc">
  306. <li><a href="../standalone/simple.html">Simple standalone editing</a></li>
  307. <li><a href="../standalone/bubble.html">Bubble editing</a></li>
  308. <li><a href="../standalone/inline.html">Inline editing</a></li>
  309. </ul>
  310. </div>
  311. <div class="toc-group">
  312. <h3><a href="../styling/index.html">Styling</a></h3>
  313. <ul class="toc">
  314. <li><a href="../styling/envelope.html">Envelope display controller</a></li>
  315. <li><a href="../styling/envelopeInTable.html">Envelope display with in table
  316. controls</a></li>
  317. <li><a href="../styling/stackedInputs.html">Styled for stacked inputs</a></li>
  318. <li><a href="../styling/bootstrap.html">Bootstrap</a></li>
  319. <li><a href="../styling/jqueryui.html">jQuery UI</a></li>
  320. </ul>
  321. </div>
  322. <div class="toc-group">
  323. <h3><a href="../plug-ins/index.html">Plug-ins</a></h3>
  324. <ul class="toc">
  325. <li><a href="../plug-ins/fieldPlugin.html">Custom field type plug-ins</a></li>
  326. <li><a href="../plug-ins/displayController.html">Custom display controller</a></li>
  327. </ul>
  328. </div>
  329. </div>
  330. <div class="epilogue">
  331. <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full
  332. information about its API properties and methods.<br>
  333. Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and
  334. <a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of
  335. DataTables.</p>
  336. <p class="copyright">DataTables designed and created by <a href=
  337. "http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2014<br>
  338. DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
  339. </div>
  340. </div>
  341. </div>
  342. </section>
  343. </body>
  344. </html>