Sorting breaking filters?

Sorting breaking filters?

sshefersshefer Posts: 5Questions: 0Answers: 0
edited September 2009 in General
Anyone else having an issue where sorting will break a current filter you have set?

I have an input box above my table that I use to filter like this:

[code]
$("input#search-listings-title").keyup(function() {
var val = $("input#search-listings-title").attr("value");
listingsTable.fnFilter(val, 1, false);
});
[/code]

However, when I type something in (and the results are narrowed) and then I sort the data the filter is removed right away.

Am I doing something wrong?

Thanks.

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Hi sshefer,

    Are you using DataTables 1.5.2 here? I sort of vaguely recall something about this issue from before, and this it is resolved now - certainly, I can't reproduce the issue here: http://datatables.net/examples/api/multi_filter.html

    Regards,
    Allan
  • sshefersshefer Posts: 5Questions: 0Answers: 0
    Yup - This was on 1.5.1 and 1.5.2...

    Here is the complete code for the datatable setup:

    [code]
    listingsTable = $('#listingsTable').dataTable({
    "bProcessing": false,
    "bPaginate": false,
    "bLengthChange": false,
    "bFilter": false,
    "bSort": true,
    "bInfo": true,
    "bAutoWidth": false,
    "sDom": '<"top"f>rt<"bottom"ilp><"clear">',
    "sPaginationType": "full_numbers",
    "aoColumns": [
    { "sType": "html" },
    { "sType": "html" },
    { "sType": "html" },
    null,
    { "bSortable": false }
    ],
    "oLanguage": {
    "sLengthMenu": "Display _MENU_ listings per page",
    "sZeroRecords": "No matching listings found - try changing your search criteria?",
    "sInfo": "Showing _START_ to _END_ of _TOTAL_ listings",
    "sInfoEmtpy": "Showing 0 to 0 of 0 job listings",
    "sInfoFiltered": "(filtered from _MAX_ total listings)",
    "sSearch": "Search all columns:"
    }
    });
    [/code]

    And here are my search fields (I should note that these are added to the page using livequery):

    [code]
    $("select#search-listings-type").change(function() {
    var val = $("select#search-listings-type option:selected").attr("value");
    listingsTable.fnFilter(val, 0, false);
    });

    $("input#search-listings-title").keyup(function() {
    var val = $("input#search-listings-title").attr("value");
    listingsTable.fnFilter(val, 1, false);
    });
    [/code]

    Anything seem out of order?
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Hi sshefer,

    Yup - this line looks a bit odd:

    [code]
    "bFilter": false
    [/code]
    If you disable filtering, then the filtering isn't going to work as expected :-). So you need to set this to 'true', and if you don't want the global filtering input element that DataTables puts on the page, drop the 'f' options from sDom.

    Regards,
    Allan
  • sshefersshefer Posts: 5Questions: 0Answers: 0
    Aha!

    Thanks for that - didn't realize it worked that way. :)
This discussion has been closed.