Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82136

Filtering Array of Objects by attribute and not by array Index

$
0
0
I want to create a date range filter that can be applied to a number of datatables. The problem I am having is even though I am passing
in my aaData value as an array of objects by the time I get to the filter function it is in an array. This wont work because the index of the date value in the array is different in the various dataTables throughout my application and I would much rather be able to do it via dot notation on an attribute something like this.

$.fn.dataTableExt.afnFiltering.push(
        function( oSettings, aData, iDataIndex ) {
            var iMin = document.getElementById('start-datepicker').value;
            var iMax = document.getElementById('end-datepicker').value;
 
            // Create Minimum Date Object
            var iMinDate = new Date(iMin);
 
            // Create Maximum Date Object
            var iMaxDate = new Date(iMax);
 
            // Create Date Column Object
            var iDateStr = aData.date;
            var iDate = new Date(iDateStr);
 
            if ( iMinDate < iDate && iDate < iMaxDate )
            {
                return true;
            }
            return false;
        }
    );

Viewing all articles
Browse latest Browse all 82136

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>