Filter does not work $.fn.dataTableExt.afnFiltering.push
-
Hello you great plugin I made it through almost anything you wanted. But faced with the same problem on a global search for the table and I think without your help I can not solve it.
I have a table with 3 columns “User ID”, “country”, “phone” that I need to have the first column “User ID” was configured with your search filter. I found the solution on datatables.net But I was faced with the fact that I can not use a filter that’s $. Fn.dataTableExt.afnFiltering.push (
in Firefox firebag produces here is TypeError: $ is undefined
$. fn.dataTableExt.afnFiltering.push (and thus the filter does not work.
Here’s the code<script type=’text/javascript’ src=’http://formula2013.myjino.ru/wp-content/plugins/tablepress/js/jquery.datatables.min.js?ver=1.3′></script>
<script type=”text/javascript”>
jQuery.extend($.fn.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
var inputFilters = [
{iColumn: 0, elementId: ‘count_filter’, type: ‘count’ }
];
var match = true;
for (i = 0; i < inputFilters.length; i++) {
var value = jQuery(‘#’ + inputFilters[i].elementId).val();
switch (inputFilters[i].type) {
case ‘count’:
if (value && match) {
countFilter(value, aData[inputFilters[i].iColumn]);
}
break;
}
}function countFilter(searchValue, rowValue) {
var compareChar = searchValue.charAt(0);
var compareValue = parseFloat(searchValue.substr(1, searchValue.length – 1));
rowValue = (jQuery(rowValue).text()) ? jQuery(rowValue).text() : rowValue;
match = false;
switch (compareChar) {
case ‘<‘:
if (compareValue > rowValue) match = true;
break;
case ‘>’:
if (compareValue < rowValue) match = true;
break;
case ‘=’:
if (compareValue == rowValue) match = true;
break;
default:
if (searchValue == rowValue) match = true;
}
}return match;
}
)
);
</script><script type=”text/javascript”>
jQuery(document).ready(function($){
var DataTables_oLanguage={};
DataTables_oLanguage[“ru_RU”]={“sProcessing”: “Подождите…”,”sLengthMenu”: “Показать _MENU_ записей”,”sZeroRecords”: “Записи отсутствуют.”,”sInfo”: “Показаны записи с _START_ по _END_ из _TOTAL_ записей”,”sInfoEmpty”: “Выбрано записи с 0 по 0 из 0 записей”,”sInfoFiltered”: “(выбрано из _MAX_ записей)”,”sInfoPostFix”: “”,”sSearch”: “Найти:”,”oPaginate”: {“sFirst”: “Первая”,”sPrevious”: “Предыдущая”,”sNext”: “Следующая”,”sLast”: “Последняя”}};
$(‘#tablepress-1’).dataTable({“oLanguage”:DataTables_oLanguage[“ru_RU”],”aaSorting”:[],”aoColumnDefs”:[ { “sType”: “number”, “aTargets”: [ 0 ] } ],”bSortClasses”:false,”asStripeClasses”:[‘even’,’odd’],”bPaginate”: false,”bSort”:false,”bLengthChange”:false,”iDisplayLength”:1,”bInfo”:false,”oSearch”: {“sSearch”: “<? echo $id_nickname; ?>”}});$(‘#count_filter’).keyup(function() {
dataTable.fnFilter(”, 0);});
});</script>
<input type=”text” name=”count_filter” id=”count_filter” value=”” />
<?phpecho do_shortcode(‘[table id=1 /]’);
?>
I hope very much for your help
The topic ‘Filter does not work $.fn.dataTableExt.afnFiltering.push’ is closed to new replies.