Filter example code Version 1.10 not working

Filter example code Version 1.10 not working

BmokryBmokry Posts: 2Questions: 2Answers: 0

Still learning DataTables. Trying to get a simple filter to work. The example code in the API reference .filter() section does not filter my table. Code for older version of DataTables I found through Google search does (commented out in code below). What am I doing wrong using the example code?

var table = $('#1728ReportEdit').DataTable( {
    dom: 'Bfrtip',
    ajax: "php/table.1728ReportEdit.php",

    columns: [
        {
            "data": "cnum"
        },
        {
            "data": "progcategory"
        },
        {
            "data": "purposeactivity"
        },
        {
            "data": "projecttitle"
        },
        {
            "data": "moneyraised"
        },
        {
            "data": "hourscount"
        },
        {
            "data": "date"
        },

    ],


    buttons: [
        {  extend: 'collection',
            text: 'Export',
            buttons: [
                'copy',
                'excel',
                'csv',
                'pdf',
                'print'
            ]
        },
        { extend: 'create', editor: editor },
        { extend: 'edit',   editor: editor },
        { extend: 'remove', editor: editor }
    ]


} 



);

// var filtercnum = '8285',
// filterIndex = 0;
//
//$.fn.dataTableExt.afnFiltering.push(
// function( oSettings, aData, iDataIndex ) {
// return aData[filterIndex].indexOf(filtercnum)>-1;
// }
//);

var filteredData = table
.column(0)
.data()
.filter( function ( value, index ) {
return value = 8285 ? true : false;
} );

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Please don't post duplicates.

    I've replied in the other thread, so I'll close this one.

    Allan

This discussion has been closed.