Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35449

Access table data by column name (not index number) in filter

$
0
0

Hello,

I am happily using datatables and I added filters which work well:

    //filtering function
    $.fn.dataTable.ext.search.push(
            function( settings, data, dataIndex ) 
            {

        //Price range
                var price_min = $('#price_min').val() * 1;
                var price_max = $('#price_max').val() * 1;
                var price = parseFloat( data[7] ) || 0; // price column
                if ( ( price_min != '' && price < price_min ) ||  ( price_max != '' && price > price_max ) )
                    return false;

                return true;
            }
        ); 

=> I would like to improve the code by accessing data by column name ( e.g. : data['prix'] ) rather than index number ( data[7] )

Thank you in advance for your help !


Viewing all articles
Browse latest Browse all 35449

Trending Articles