filtering stops working after check all implemented

filtering stops working after check all implemented

giorgio79giorgio79 Posts: 43Questions: 0Answers: 0
edited September 2010 in General
[code]
var oTable;

$(document).ready(function() {
$('#check_all').click( function() {
//var oTable = $('#bookmark-project').dataTable();

$('input', oTable.fnGetFilteredNodes()).attr('checked',this.checked);
} );


var oTable = $('#bookmark-project').dataTable( {
//"fnInitComplete" : function () {$('#check_all').click( function() {$('input[name*=\'include\']', oTable.fnGetFilteredNodes()).attr('checked',this.checked);});},
"bPaginate": false,
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"aoColumns": [
{ "sSortDataType": "dom-text" },
{ "sSortDataType": "dom-text" },
{ "sSortDataType": "dom-text" },
{ "sSortDataType": "dom-checkbox" },
{ "sSortDataType": "dom-checkbox"},
{ "sSortDataType": "dom-checkbox"},
]
} );

[/code]


Hello,

With the above code, after the first click on checkall, filtering stops working and always returns "no results". Somehow I suspect it has to do with how the code handles oTable, but I am clueless...

I left the fnInitcomplete solution commented out there as I could not get it to work, although it was suggested here:
http://datatables.net/forums/comments.php?DiscussionID=276

Any tips are appreciated.

Cheers,
G

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Odd that filtering would stop working. Are you getting any Javascript errors?

    Allan
  • giorgio79giorgio79 Posts: 43Questions: 0Answers: 0
    Thanks Allan, here we go:

    a is undefined
    [Break on this error] Failed to load source for: .../media/js/jquery.dataTables.min.js?b

    The table initializes fine, not sure why all of a sudden it is not finding datatables file. If I remove the search box text, the table loads back fine!

    Found the same issue as well http://datatables.net/forums/comments.php?DiscussionID=1908&page=1 although I am not using other libraries. I am using Drupal, and including the library on a page.

    This may be related as well:
    http://datatables.net/forums/comments.php?DiscussionID=2411


    I checked and inserted the checkbox in your demo with the DOM Sort and there it works flawlessly.

    Could be a jquery version clash? What version should we be using of jquery?
  • giorgio79giorgio79 Posts: 43Questions: 0Answers: 0
    Meanwhile figured this out.

    I had to put an event.stopPropagation in the clickall function, since the checkall button is in thead column, that also has sorting enabled which was clashed :)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited September 2010
    Ah good stuff! Thanks for the update. Good to hear you got it sorted.

    Edit: I should have said. I'd always recommend using the latest stable release of jQuery. 1.3 should still work though, and quite probably 1.2.

    Allan
This discussion has been closed.