Title: Default DataTables Javascript Options for import
Last modified: August 21, 2016

---

# Default DataTables Javascript Options for import

 *  Resolved [Michael Aronoff](https://wordpress.org/support/users/masterk/)
 * (@masterk)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/default-datatables-javascript-options-for-import/)
 * I am doing a bulk import of over 100 tables. I have noticed that I will still
   have to click into each one and disable the DataTables features I want for each.
   It would be great if there were a way to set the “default” options so that when
   data is imported I do not have to still edit each and every table.
 * Either that or set the options in the shortcode.
 * Basically I want to have Horizontal Scrolling but all the other options off.
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/default-datatables-javascript-options-for-import/#post-5083968)
 * Hi,
 * thanks for your question, and sorry for the trouble.
 * I see what you mean, and the best way to achieve this should be through temporarily
   using a plugin filter hook to change the default options for new tables.
    For
   that, just add the following code into your theme’s “functions.php”:
 *     ```
       add_filter( 'tablepress_table_template', 'tablepress_change_default_values' );
       function tablepress_change_default_values( $default_table ) {
       	$default_table['options']['datatables_sort'] = false;
       	$default_table['options']['datatables_filter'] = false;
       	$default_table['options']['datatables_paginate'] = false;
       	$default_table['options']['datatables_lengthchange'] = false;
       	$default_table['options']['datatables_info'] = false;
       	return $default_table;
       }
       ```
   
 * You can then remove that after importing your 100 tables, if you which to return
   to the original default values.
 * Other options would be to use a (different) plugin filter hook to manually override
   the state of the checkboxes, see [http://wordpress.org/support/topic/searching-and-sorting-1?replies=3](http://wordpress.org/support/topic/searching-and-sorting-1?replies=3).
 * You could also use Shortcode parameters, if you want, see [http://tablepress.org/faq/documentation-shortcode-table/](http://tablepress.org/faq/documentation-shortcode-table/).
 * Finally, if you only want Horizontal Scrolling, it might make sense to turn off
   DataTables for those tables completely (you would then use
 *     ```
       $default_table['options']['use_datatables'] = false;
       ```
   
 * in the code above, and use a “Custom CSS” solution instead:
 *     ```
       .tablepress-scroll-wrapper {
         overflow-x: auto;
         overflow-y: hidden;
       }
       ```
   
 * For that, you can tell TablePress to automatically add that `<div>` to all tables
   with this PHP code in the “functions.php”:
 *     ```
       add_filter( 'tablepress_table_output', 'tp_add_scroll_wrapper', 10, 3 );
       function tp_add_scroll_wrapper( $output, $table, $render_options ) {
         $output = "<div class=\"tablepress-scroll-wrapper\">\n{$output}\n</div>";
         return $output;
       }
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [Michael Aronoff](https://wordpress.org/support/users/masterk/)
 * (@masterk)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/default-datatables-javascript-options-for-import/#post-5084006)
 * Thanks this worked great. Just one last question.
 * I put the code into my functions.php to override the defaults. Can I safely leave
   that there? I mean will it just effect the defaults for a new table or will it
   override everything. I have a few very long tables I will be using the paginate
   for.
 * Thanks!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/default-datatables-javascript-options-for-import/#post-5084018)
 * Hi,
 * no problem, you are very welcome! 🙂 Good to hear that this helped!
 * Yes, you can leave that code in the “functions.php”. It will only affect tables
   that are newly added or imported after the code was added to the “functions.php”.
   Tables that existed previously will not be touched, and you can off course still
   change all tables as necessary.
 * Best wishes,
    Tobias
 * P.S.: In case you haven’t, please [rate TablePress](https://wordpress.org/support/view/plugin-reviews/tablepress)
   here in the plugin directory. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Default DataTables Javascript Options for import’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/default-datatables-javascript-options-for-import/#post-5084018)
 * Status: resolved