Uncaught TypeError: Cannot read property 'oFeatures' of null

Uncaught TypeError: Cannot read property 'oFeatures' of null

stephenyostephenyo Posts: 6Questions: 0Answers: 0
edited July 2012 in General
Hi- I'm attempting to use the fnFilterAll plugin, but cannot seem to get it up and running.

I have 2 tables. As it stands right now, I am able to search both (when bFilter is set to true) individually. I would like my 'global' search filter to search on both tables.

I'm currently receiving an error: "Uncaught TypeError: Cannot read property 'oFeatures' of null" when I type into he filter.

Anyone have any ideas as to what could be going on here? I've spent about two hours trying to determine the null variable.

You can see the site at https://support.toptix.com/staff/kbsearch.php

I would post the debug, but it is giving me a JSON parsing error.

My code:

[code]






$(document).ready(function () {



$("tr").hover(function () {
$(this).addClass("hover");
},
function () {
$(this).removeClass("hover");
});





var oTable = $("#kbsearch").dataTable( {
"bPaginate": true,
"bLengthChange": false,
"oLanguage": {
"sSearch": "",
"oPaginate": {
"sNext": " Next >",
"sPrevious": "< Previous "
}
}

});

$("#ticketsearch").dataTable( {
"bFilter": false
});


$("#kbsearch_filter input").keyup( function () {
// Filter on the column (the index) of this element
oTable.fnFilterAll(this.value);

} );






$('#kbsearch_filter :input:visible:enabled:first').focus();
$("#kbsearch_filter input").val('Search Knowledgebase and Tickets by all Columns');
$("#kbsearch_filter input").addClass("gray");
$("#kbsearch_filter input").click(function() {
$(this).val('');
$(this).removeClass("gray");
});






});

[/code]

Replies

  • stephenyostephenyo Posts: 6Questions: 0Answers: 0
    Also- Chrome dev tools gives me this:

    Uncaught TypeError: Cannot read property 'oFeatures' of null jquery.dataTables.js:5419

    DataTable.fnFilter jquery.dataTables.js:5419

    $.fn.dataTableExt.oApi.fnFilterAll datatables.fnFilterAll.js:12

    DataTable.oApi._fnExternApiFunc jquery.dataTables.js:6077

    (anonymous function) kbsearch.php:46

    jQuery.event.dispatch jquery-1.7.2.js:3332

    jQuery.event.add.elemData.handle.eventHandle jquery-1.7.2.js:2941
  • allanallan Posts: 63,541Questions: 1Answers: 10,476 Site admin
    That's interesting - what you've got looks like it should work. Could you link me to a test page with the issue so I can debug it please?

    Allan
  • stephenyostephenyo Posts: 6Questions: 0Answers: 0
    sure thing- https://support.toptix.com/staff/filterall.php
  • allanallan Posts: 63,541Questions: 1Answers: 10,476 Site admin
    Thanks - i suspect that the problem is that you have turned filtering off on the second table, but are still trying to filter the table! You have bFilter:false which completely disabled filtering - if you want to just remove the input control that DataTables puts in place, just drop the 'f' option from sDom . Hopefully that will do it.

    Allan
  • stephenyostephenyo Posts: 6Questions: 0Answers: 0
    Bugger- same issue after the change was made.

    Do you think it could have anything to do with the fact that JSLINT tells me I have a parser error?
  • allanallan Posts: 63,541Questions: 1Answers: 10,476 Site admin
    Hmmm - looking the plug-in and it actually looks a little dodgy to me (which is odd, since I've seen it working before). Try this and see if it helps:

    [code]
    $.fn.dataTableExt.oApi.fnFilterAll = function(oSettings, sInput, iColumn, bRegex, bSmart) {
    var settings = $.fn.dataTableSettings;
    for ( var i=0 ; i
  • stephenyostephenyo Posts: 6Questions: 0Answers: 0
    That took care of it! Can you tell me what the issue was with the Plugin?
  • allanallan Posts: 63,541Questions: 1Answers: 10,476 Site admin
    edited July 2012
    The use of 'this' in the plug-in looked rather dodgy - it was assuming two different, independent things about the scope of execution (that it had access to dataTableSettings, i.e. $.fn, and the DataTables API methods, i.e the table instance).

    It must have worked by fluke (certainly not by the DataTables API design) in older versions, but 1.9 cleaned a lot of things up, and it must have taken this quick out.

    Sorry I didn't pick that up immediately, but thanks very much for letting me know about this! I've committed the fix to the plug-ins repo and its up on the site now.

    Interestingly enough, with DataTables 1.10 I'm planning on updating the whole API to be able to do this kind of thing (apply to multiple tables), thus removing the need for the plug-in: http://datatables.net/development/roadmap :-)

    Allan
  • stephenyostephenyo Posts: 6Questions: 0Answers: 0
    Excellent!

    I look forward to the new release!
This discussion has been closed.