Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery UI breaking all other tables on website
    primarykey
    data
    text
    <p>I am using a jquery script called datatables, this adds a lot of functions to your tables like searching and filtering etc and enables you to skin the tables with the jquery ui. I am trying to replicate the following example on my website so that I can filter columns. <a href="http://www.datatables.net/release-datatables/examples/api/multi_filter_select.html" rel="nofollow">http://www.datatables.net/release-datatables/examples/api/multi_filter_select.html</a> The problem I am having now, is when I use the following script on my website it strips away the jquery ui on all the other tables.</p> <p>For example on one of the other tables I have this set in the of the page : </p> <pre><code> $(document).ready( function() { $('#mailinglistmanager').dataTable( { "bJQueryUI": true, "bInfo": true, "bAutoWidth": true, "bFilter": false, "bLengthChange": true, "bPaginate": true, "bProcessing": true, "bSort": true, "sPaginationType": "full_numbers", "aaSorting": [[ 6, "desc" ]], "iDisplayLength": 100, "bLengthChange": false } ); }); &lt;/script&gt; </code></pre> <p>this and the other tables seem to work fine until I add the code below, then what happens is the other tables are stripped of the jquery ui and only the table defined below is skinned then, and all the other tables are then unskinned.</p> <pre><code> (function($) { /* * Function: fnGetColumnData * Purpose: Return an array of table values from a particular column. * Returns: array string: 1d data array * Inputs: object:oSettings - dataTable settings object. This is always the last argument past to the function * int:iColumn - the id of the column to extract the data from * bool:bUnique - optional - if set to false duplicated values are not filtered out * bool:bFiltered - optional - if set to false all the table data is used (not only the filtered) * bool:bIgnoreEmpty - optional - if set to false empty values are not filtered from the result array * Author: Benedikt Forchhammer &lt;b.forchhammer /AT\ mind2.de&gt; */ $.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) { // check that we have a column id if ( typeof iColumn == "undefined" ) return new Array(); // by default we only wany unique data if ( typeof bUnique == "undefined" ) bUnique = true; // by default we do want to only look at filtered data if ( typeof bFiltered == "undefined" ) bFiltered = true; // by default we do not wany to include empty values if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true; // list of rows which we're going to loop through var aiRows; // use only filtered rows if (bFiltered == true) aiRows = oSettings.aiDisplay; // use all rows else aiRows = oSettings.aiDisplayMaster; // all row numbers // set up data array var asResultData = new Array(); for (var i=0,c=aiRows.length; i&lt;c; i++) { iRow = aiRows[i]; var aData = this.fnGetData(iRow); var sValue = aData[iColumn]; // ignore empty values? if (bIgnoreEmpty == true &amp;&amp; sValue.length == 0) continue; // ignore unique values? else if (bUnique == true &amp;&amp; jQuery.inArray(sValue, asResultData) &gt; -1) continue; // else push the value onto the result data array else asResultData.push(sValue); } return asResultData; }}(jQuery)); function fnCreateSelect( aData ) { var r='&lt;select&gt;&lt;option value=""&gt;&lt;/option&gt;', i, iLen=aData.length; for ( i=0 ; i&lt;iLen ; i++ ) { r += '&lt;option value="'+aData[i]+'"&gt;'+aData[i]+'&lt;/option&gt;'; } return r+'&lt;/select&gt;'; } $(document).ready(function() { /* Initialise the DataTable */ var oTable = $('#dashboard').dataTable( { "bJQueryUI": true, "bInfo": true, "bAutoWidth": true, "bFilter": true, "bLengthChange": true, "bPaginate": true, "bProcessing": true, "bSort": true, "sPaginationType": "full_numbers", "aaSorting": [[ 9, "desc" ]], "iDisplayLength": 5, "bLengthChange": false } ); /* Add a select menu for each TH element in the table footer */ $("tfoot th").each( function ( i ) { this.innerHTML = fnCreateSelect( oTable.fnGetColumnData(i) ); $('select', this).change( function () { oTable.fnFilter( $(this).val(), i ); } ); } ); } ); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload