Sort not working (using WP-Table Reloaded)

Sort not working (using WP-Table Reloaded)

ryanburnettryanburnett Posts: 2Questions: 0Answers: 0
edited March 2011 in General
http://bit.ly/iks99g

I've installed the plugin WP-Table Reloaded, which includes the DataTables library.

The table sort will not work, either ascending or descending.

The table is using and , I read through the DataTables FAQs and searched the forums and cannot find a solution. Your help is greatly appreciated.

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Hi ryanburnett,

    Thanks very much for the link :-). It's a curious one this, but I think I know what is going on. Your site is hosted on the sub-domain champions.stanford.edu, however you are loading a language file via Ajax from a different domain:

    [code]
    "oLanguage":{"sUrl": "https://www.stanford.edu/dept/athletics/cgi-bin/champions/wp-content/plugins/wp-table-reloaded/languages/datatables/lang-en_US.txt"}
    [/code]
    This appears to be triggering the cross site scripting protection in browsers and just killing the initialisation of DataTables stone dead. It gets part way through (for example you can call the fnSort function manually) but doesn't complete the DOM initialisation since it needs the language file which it can't get.

    So there are a couple of options which spring to mind:

    1. Remove the oLanguage option from the DataTables initialisation. Does WP-Table Reloaded allow that?
    2. Host the script and language file on your sub-domain

    Hope this helps!

    Regards,
    Allan
  • ryanburnettryanburnett Posts: 2Questions: 0Answers: 0
    edited March 2011
    Hi Allan,

    Thanks for the quick reply!

    You're right - the problem was domain related. The site is hosted at the longer domain, but our IT dept setup a reverse proxy for the short URL. So there's really no way to host the files on the sub-domain.

    I just found a solution to the problem from the WP-Table Reloaded author Tobias on the WordPress support forum:

    http://bit.ly/gICt3X

    His solution is to add this to my theme's functions.php file:
    [code]
    function adjust_wp_table_reloaded_url_datatables_language_file( $url ) {
    return 'https://champions.stanford.edu/wp-content/plugins/wp-table-reloaded/languages/datatables/lang-en_US.txt';
    }
    add_filter( 'wp_table_reloaded_url_datatables_language_file', 'adjust_wp_table_reloaded_url_datatables_language_file' );
    [/code]
    Thanks for your help and your awesome DataTables library!
This discussion has been closed.