• Resolved MAXIS322718_m

    (@maxis322718_m)


    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&gt;

    <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=”” />
    <?php

    echo do_shortcode(‘[table id=1 /]’);

    ?>
    I hope very much for your help

    https://wordpress.org/plugins/tablepress/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    So, the problem is that $.fn.dataTableExt.afnFiltering.push is not recognized?
    Can you try jQuery.fn.dataTableExt.afnFiltering.push?

    Regards,
    Tobias

    Thread Starter MAXIS322718_m

    (@maxis322718_m)

    Thank you very much.
    Everything worked as you said. Tell me is it possible to achieve the same result using only global search table. what would
    in the User ID field with a unique id in the water in the search box
    such as the number 1 deduced only by 1 and not 1,10,100?

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    good to hear that this helped!
    Unfortunately, I don’t understand what you mean with that other question. I’m not really an expert with the DataTables internals, so I don’t know what would be necessary for that. Sorry.

    Regards,
    Tobias

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

The topic ‘Filter does not work $.fn.dataTableExt.afnFiltering.push’ is closed to new replies.