Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. CREATE TABLE `id` (
  2. `id` int(10) NOT NULL auto_increment,
  3. `first` varchar(255) default NULL,
  4. `last` varchar(255) default NULL,
  5. `age` varchar(255) default NULL,
  6. PRIMARY KEY (`id`)
  7. );
  8.  
  9. $this->enqueueStyle(
  10. dirname( APFDEMO_FILE ) . '/datatables/css/demo.css',
  11. 'apf_first_page' // page slug
  12. );
  13. $this->enqueueStyle(
  14. dirname( APFDEMO_FILE ) . '/datatables/css/jquery.dataTables.css',
  15. 'apf_first_page' // page slug
  16. );
  17. $this->enqueueStyle(
  18. dirname( APFDEMO_FILE ) . '/datatables/css/dataTables.tableTools.css',
  19. 'apf_first_page' // page slug
  20. );
  21. $this->enqueueStyle(
  22. dirname( APFDEMO_FILE ) . '/datatables/css/dataTables.editor.css',
  23. 'apf_first_page' // page slug
  24. );
  25.  
  26. $this->enqueueScript(
  27. dirname( APFDEMO_FILE ) . '/datatables/js/jquery.dataTables.min.js', // source url or path
  28. 'apf_first_page', // page slug
  29. '', // tab slug
  30. array(
  31. 'handle_id' => 'my_dataTables_script', // this handle ID also is used as the object name for the translation array below.
  32. )
  33. );
  34.  
  35. $this->enqueueScript(
  36. dirname( APFDEMO_FILE ) . '/datatables/js/dataTables.tableTools.min.js', // source url or path
  37. 'apf_first_page', // page slug
  38. '', // tab slug
  39. array(
  40. 'handle_id' => 'my_dataTablesTool_script', // this handle ID also is used as the object name for the translation array below.
  41. )
  42. );
  43.  
  44. $this->enqueueScript(
  45. dirname( APFDEMO_FILE ) . '/datatables/js/dataTables.editor.js', // source url or path
  46. 'apf_first_page', // page slug
  47. '', // tab slug
  48. array(
  49. 'handle_id' => 'my_dataTableseditor_script', // this handle ID also is used as the object name for the translation array below.
  50. )
  51. );
  52.  
  53. $(document).ready(function() {
  54. var editor = new $.fn.dataTable.Editor( {
  55. "ajax": "admin-ajax.php?action=datatables",
  56. "table": "#id",
  57. "fields": [
  58. {
  59. "label": "first",
  60. "name": "first",
  61. "type": "text"
  62. },
  63. {
  64. "label": "last",
  65. "name": "last",
  66. "type": "text"
  67. },
  68. {
  69. "label": "age",
  70. "name": "age",
  71. "type": "text"
  72. }
  73. ]
  74. } );
  75.  
  76. $('#id').dataTable( {
  77. "dom": "Tfrtip",
  78. "ajax": "admin-ajax.php?action=datatables",
  79. "columns": [
  80. {
  81. "data": "first"
  82. },
  83. {
  84. "data": "last"
  85. },
  86. {
  87. "data": "age"
  88. }
  89. ],
  90. "tableTools": {
  91. "sRowSelect": "os",
  92. "aButtons": [
  93. { "sExtends": "editor_create", "editor": editor },
  94. { "sExtends": "editor_edit", "editor": editor },
  95. { "sExtends": "editor_remove", "editor": editor }
  96. ]
  97. }
  98. } );
  99. } );
  100. <div class="container">
  101. <h1>DataTables Editor - id</h1>
  102. <table cellpadding="0" cellspacing="0" border="0" class="display" id="id" width="100%">
  103. <thead>
  104. <tr>
  105. <th>first</th>
  106. <th>last</th>
  107. <th>age</th>
  108. </tr>
  109. </thead>
  110. </table>
  111. </div>
  112.  
  113. add_action( 'wp_ajax_datatables', 'my_datatables_callback' );
  114.  
  115. function my_datatables_callback() {
  116.  
  117. include( APFDEMO_DIRNAME . '/datatables/php/table.id.php' );
  118.  
  119. die();
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement