Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE `id` (
- `id` int(10) NOT NULL auto_increment,
- `first` varchar(255) default NULL,
- `last` varchar(255) default NULL,
- `age` varchar(255) default NULL,
- PRIMARY KEY (`id`)
- );
- $this->enqueueStyle(
- dirname( APFDEMO_FILE ) . '/datatables/css/demo.css',
- 'apf_first_page' // page slug
- );
- $this->enqueueStyle(
- dirname( APFDEMO_FILE ) . '/datatables/css/jquery.dataTables.css',
- 'apf_first_page' // page slug
- );
- $this->enqueueStyle(
- dirname( APFDEMO_FILE ) . '/datatables/css/dataTables.tableTools.css',
- 'apf_first_page' // page slug
- );
- $this->enqueueStyle(
- dirname( APFDEMO_FILE ) . '/datatables/css/dataTables.editor.css',
- 'apf_first_page' // page slug
- );
- $this->enqueueScript(
- dirname( APFDEMO_FILE ) . '/datatables/js/jquery.dataTables.min.js', // source url or path
- 'apf_first_page', // page slug
- '', // tab slug
- array(
- 'handle_id' => 'my_dataTables_script', // this handle ID also is used as the object name for the translation array below.
- )
- );
- $this->enqueueScript(
- dirname( APFDEMO_FILE ) . '/datatables/js/dataTables.tableTools.min.js', // source url or path
- 'apf_first_page', // page slug
- '', // tab slug
- array(
- 'handle_id' => 'my_dataTablesTool_script', // this handle ID also is used as the object name for the translation array below.
- )
- );
- $this->enqueueScript(
- dirname( APFDEMO_FILE ) . '/datatables/js/dataTables.editor.js', // source url or path
- 'apf_first_page', // page slug
- '', // tab slug
- array(
- 'handle_id' => 'my_dataTableseditor_script', // this handle ID also is used as the object name for the translation array below.
- )
- );
- $(document).ready(function() {
- var editor = new $.fn.dataTable.Editor( {
- "ajax": "admin-ajax.php?action=datatables",
- "table": "#id",
- "fields": [
- {
- "label": "first",
- "name": "first",
- "type": "text"
- },
- {
- "label": "last",
- "name": "last",
- "type": "text"
- },
- {
- "label": "age",
- "name": "age",
- "type": "text"
- }
- ]
- } );
- $('#id').dataTable( {
- "dom": "Tfrtip",
- "ajax": "admin-ajax.php?action=datatables",
- "columns": [
- {
- "data": "first"
- },
- {
- "data": "last"
- },
- {
- "data": "age"
- }
- ],
- "tableTools": {
- "sRowSelect": "os",
- "aButtons": [
- { "sExtends": "editor_create", "editor": editor },
- { "sExtends": "editor_edit", "editor": editor },
- { "sExtends": "editor_remove", "editor": editor }
- ]
- }
- } );
- } );
- <div class="container">
- <h1>DataTables Editor - id</h1>
- <table cellpadding="0" cellspacing="0" border="0" class="display" id="id" width="100%">
- <thead>
- <tr>
- <th>first</th>
- <th>last</th>
- <th>age</th>
- </tr>
- </thead>
- </table>
- </div>
- add_action( 'wp_ajax_datatables', 'my_datatables_callback' );
- function my_datatables_callback() {
- include( APFDEMO_DIRNAME . '/datatables/php/table.id.php' );
- die();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement