Frequently Asked Questions (FAQ)
Sorting or other JavaScript functions are not working

If the “Use DataTables” checkbox is checked on a table’s “Edit” screen, but functions like sorting, search, pagination, or from TablePress Extensions are not working in your tables, this usually indicates a JavaScript problem.

To check for that, please use the built-in “Developer Tools” of your browser. Right click your page and pick “Inspect Element” (in Chrome, Firefox, and Opera) or press the F12 key (in Internet Explorer). You should then see the “Developer Tools”, where you can switch to the “Console” tab to see JavaScript problems on the page.

Depending on the shown error messages, we can then narrow down the cause. Here’s a list of common possible error messages and their causes:

Error: Uncaught TypeError: Cannot read property 'mData' of undefined

This error message indicates a problem with the table structure. The DataTables JavaScript library requires that the table has a rectangular structure, which means that every row must have the same number of cells. Unfortunately, this means that it is not possible to use both the JavaScript features and cell merging/combining, using the #colspan# or #rowspan# keywords, at the same time. You will have to decide what’s more important for your table: Using the JavaScript features or combining cells. Having both for one table is not possible.

If you are not using the #colspan# or #rowspan# keywords in the affected table, chances are high that the HTML code in your table is broken somewhere. A visual indicator for this can be tha content or cells in the table are shifted, e.g. they are shown on the left of the other cells in the same column. Very often, this happens when using HTML code for a link in the table. It is very important that e.g. quotation marks " are used properly around the values of HTML tag attributes, e.g. around the URL after the href= attribute. Please check that this is the case for all HTML tags in your table.

Error: Uncaught ReferenceError: jQuery is not defined

A common reason for this error message is the use of plugins that minify, concatenate, or try to optimize the loading of JavaScript or CSS files on your site. Due to the large variety of plugins, these sometimes can not properly maintain script dependencies or the necessary loading order of files. If you see this error, you should therefore try again after temporarily deactivating any such JavaScript/CSS optimization plugins.

Another reason for this is error could be that an old and outdated version of the jQuery JavaScript library is loaded on your site. There are some themes and plugins that still do this, even though WordPress already ships with the correct and up-to-date version of jQuery. To check for this, please search the generated HTML source code of the page with the table (accessible via the “View Source” feature in your browser) for the string jquery. If there’s more than one result within HTML <script> tags, this means that the library is loaded multiple times. If that is the case, the loading of the old versions should be stopped, so that only the version that comes with WordPress is loaded. This usually means deleting a line similar to

<script type="text/javascript" src="<?php bloginfo('template_url');?>/js/jquery.js"></script>

from the theme’s “header.php” file. Other variants are lines like

wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', ... );

in the “functions.php” file.

No or other error messages

If you don’t see any JavaScript errors, please make sure that the “Use DataTables” checkbox is really checked on the table’s “Edit” screen. Please also check if the JavaScript code load and initialize the DataTables JavaScript library is part of the generated HTML source code of the page. To check for this, please search that source code (again accessible via the “View Source” feature in your browser) for e.g. “datatable”.

If you are seeing other error messages than those from above, or if you are seeing other unexpected behavior of the JavaScript library, please open a new topic in the TablePress support forums, and make sure to include a link to the page with the table where this error happens!

Top