Search not searching correctly

Search not searching correctly

madrussamadrussa Posts: 3Questions: 0Answers: 0
edited June 2010 in General
Hello,

I'm quite new to jQuery and DataTables but have been doing JS for a while and normally use Mootools. I've setup a data tables and added a few enhancements to it. The problem I am getting now is that my search isnt returning the correct results.

For example I have a AJAX JSON source of:
["ProductID", "Title", "Subtitle", "Description", "Keywords", "points", "currency", "available"]
[INT, STRING, STRING, STRING, STRING, INT, FLOAT, BOOLEAN]

In that source for example I have 15 products for SONY, but when searching for SONY it only returns 3 results which isn't correct. Below is the current code:

[code]
oTable = $('#ProductsDataTable').dataTable({
"sDom": '<"H"<"searchbox"l>fr><"advanced">t<"F"ip>',
"oLanguage": {
"sLengthMenu": 'Display 51020304050All records'
},
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aaSorting": [[ 2, "asc" ]],
"aoColumns": [
{ "bSearchable": false, "sName": "ProductId", "bVisible": false },
{ "bSearchable": false, "sTitle": "Image", "bSortable": false, "fnRender": renderImage, "sClass":"al_c" },
{ "bSearchable": true, "sTitle": "Product", "bSortable": true, "fnRender": renderTitle },
{ "bSearchable": true, "sTitle": "Description", "bSortable": true, "bVisible": false, "sType": "html" },
{ "bSearchable": false, "sTitle": "Keywords", "bSortable": true, "bVisible": false },
{ "bSearchable": false, "sTitle": "Points", "bSortable": true, "fnRender": renderPoints, "sClass":"al_c", "sType":"formattednumber" },
{ "bSearchable": false, "sTitle": "Currency", "bSortable": true, "bVisible": false, "fnRender": renderCurrency, "sClass":"al_c", "sType":"formattednumber" },
{ "bSearchable": false, "sTitle": "Action", "bSortable": false, "fnRender": renderAction, "sClass":"al_c" }
],
"iDisplayLength": 5,
"bProcessing": true,
"sAjaxSource": '/ajax_source.php',
"bAutoWidth": false
});

var renderImage = function ( oObj ) {
text= '';
text+= '';
return text;
}
var renderAction = function ( oObj ) {
if(oObj.aData[5] >= 0 && 0 != 0 && !oObj.aData[7]) {
return '';
} else {
if(oObj.aData[7]) {
return 'Currently unavailable';
} else {
return 'Not enough funds!';
}
}
}

var renderInfo = function ( oObj ) {
return '';
}
var renderTitle = function ( oObj ) {
return oObj.aData[1] +' '+ oObj.aData[2];
}
var renderPoints = function ( oObj ) {
return addCommas(oObj.aData[5]);
}
var renderCurrency = function ( oObj ) {
return '£'+(oObj.aData[6].toFixed(2));
}
var fnFormatDetails = function( nTr ) {
var aData = oTable.fnGetData( nTr );
var sOut = '';
sOut += '';
sOut += ''+aData[2]+' '+aData[3]+'';
sOut += ' ';
return sOut;
}
[/code]

There are a few other changes but I dont think they'll be effecting the results. They are only to do row highlighting and when clicking on a row to nicely slide the description into view. Hence the fnCloseNicely.

Any help would be great thanks!

Russell

Replies

  • madrussamadrussa Posts: 3Questions: 0Answers: 0
    More code that I couldn't fit in

    [code]
    $.fn.dataTableExt.oApi.fnCloseNicely = function(oSettings, nTr ){
    for ( var i=0 ; i
  • madrussamadrussa Posts: 3Questions: 0Answers: 0
    Update:

    I've found that it is not searching correctly in the following browsers:
    FireFox 3.6
    FireFox 2
    Chrome 5
    Safari 4

    It is however working fine in:
    IE6
    IE7
    IE8

    I saw in another post that had a similar problem it was some comment tags in the table, but this is from JSON and the table has no comments.
This discussion has been closed.