dataTables searchbox not working propperly

dataTables searchbox not working propperly

zinhozinho Posts: 3Questions: 3Answers: 0

have an issue with the dataTables searchbox - it doesn't show the correct results when search is preformed.

Please note that the search box is not located in the dataTables but in the header of the page that is loaded separately.

For example : In the creator column I have 10 same creators fuzz@buzz.com but when I type in the searchbox "Fuzz" it only gives me 2 or 3 results not the all 10.

Any idea what could be wrong here?

Thank you

This is the dataTables code :

ticketsDT = $('#stickets_table').dataTable({
/'oLanguage': {
'sUrl': '/js/datatables/trans/dataTables.croatian.txt'
},
/

bProcessing: true,
bServerSide: true,
sAjaxSource: "/supporttickets/tickets_data",
aLengthMenu: [[25, 50, 100, -1], [25, 50, 100, "All"]], iDisplayLength : 25,
sDom: 'C<"#table_heading_right2"l>Rrtip',
oColVis: {
    "aiExclude": [ 0, 1, 5, 7 ]
},
bStateSave: true,
fnServerData: function ( sSource, aoData, fnCallback ) {
    /*
    var status_values = $("#filter_status").val();
    var priority_values = $("#filter_priority").val();
    var owner_values = $("#filter_owner").val();
    var cc_values = $("#filter_cc").val();
    var account_values = $("#filter_account").val();
    var search_text = $("#header_search_input").val();
    */
    // TODO add date filters

    var s_val = $("#filter_status_new").sortfilt( 'getSelected' );
    var p_val = $("#filter_priority_new").sortfilt( 'getSelected' );
    var o_val = $("#filter_owner_new").sortfilt( 'getSelected' );
    var cc_val = $("#filter_cc_new").sortfilt( 'getSelected' );
    var acc_val = $("#filter_account_new").sortfilt( 'getSelected' );
    var st = $("#header_search_input").val();


    aoData.push({
        name: 'status_values',
        value: s_val
    });
    aoData.push({
        name: 'priority_values',
        value: p_val
    });
    aoData.push({
        name: 'owner_values',
        value: o_val
    });
    aoData.push({
        name: 'cc_values',
        value: cc_val
    });
    aoData.push({
        name: 'account_values',
        value: acc_val
    });
    aoData.push({
        name: 'search_text',
        value: st
    });
    aoData.push({
        name: 'deadline_filter',
        value: deadline_filter
    });
    aoData.push({
        name: 'created_filter',
        value: created_filter
    });
    aoData.push({
        name: 'custom_sort_col',
        value: custom_sort.col
    });
    aoData.push({
        name: 'custom_sort_dir',
        value: custom_sort.dir
    });

    var hash_obj = {
        status_values: '',
        priority_values: '',
        owner_values: '',
        cc_values: '',
        account_values: '',
        search_text: st,
        created_filt: created_filter,
        deadline_filt: deadline_filter
    };

    if( s_val && s_val.length > 0 ) {
        hash_obj.status_values = s_val.join(',');
    }

    if( p_val && p_val.length > 0 ) {
        hash_obj.priority_values = p_val.join(',');
    }

    if( o_val && o_val.length > 0 ) {
        hash_obj.owner_values = o_val.join(',');
    }

    if( cc_val && cc_val.length > 0 ) {
        hash_obj.cc_values = cc_val.join(',');
    }

    if( acc_val && acc_val.length > 0 ) {
        hash_obj.account_values = acc_val.join(',');
    }

    var hsh = $.param( hash_obj );
    //console.log("hash : "+hsh);
    location.hash = hsh;
    // TODO add more data if needed!!!
    $.getJSON( sSource, aoData, function (json) { 
        fnCallback(json)
    });
},
sPaginationType: 'full_numbers',
// aaSorting: [[ 4, "desc" ], [6, "desc"]], // order by priority, time. alen commented out, first view takes 10+ sec with 2 order by
        aaSorting: [[5, "desc"]], // order by creation date
bDestroy: true,
aoColumns: [
    { "sName": 'st_from_name',"sClass": 'ticket_creator_cell', 'bVisible': true },
    { "sName": 'st_title', "sClass": 'ticket_title_cell', 'bVisible': true },
    { "sName": 'stsa_name',"sClass": 'ticket_account_cell', 'bVisible': false },
    { "sName": 'st_status',"sClass": 'ticket_status_cell', 'bVisible': false },
    { "sName": 'st_owner',"sClass": 'ticket_owner_cell', 'bVisible': false },
    { "sName": 'st_creation_datetime',"sClass": 'ticket_creation_cell', 'bVisible': true },
    { "sName": 'st_deadline',"sClass": 'ticket_deadline_cell', 'bVisible': false  },
    { "sName": 'st_attachments',"sClass": 'ticket_attachments_cell', 'bVisible': false }
],
fnInitComplete: function(oSettings, json) {
    jQuery('#table_heading_right2').appendTo('#show_entries');
    jQuery('.ColVis').prependTo('#colvis_wrapper');
    jQuery('.ColVis_collection').prependTo('#colvis_wrapper');
},
fnRowCallback: function( nRow, aData, iDisplayIndex ) {
    /*// $(nRow).attr('id_ticket', aData.id_ticket);
    $(nRow).click({ id_support_ticket: aData.id_support_ticket }, function(event) {
        window.location = '/supporttickets/ticket_details/' + event.data.id_support_ticket;
    });*/
}

});

and this is the the search box keyup function that calls/triggers the search

var filter_timeout;
$('#header_search_input').keyup(function(){

if( filter_timeout ) {
    clearTimeout( filter_timeout );
}
filter_timeout = setTimeout(function(){
    ticketsDT.fnFilter();
}, 400);

});

This discussion has been closed.