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

fnSetFilteringDelay Plugin Column Header Search

$
0
0
I was trying to figure out how to get the delay plugin to work when using the column header search instead of the global search. I came up with the code below if this is useful to anyone else:

jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function (oSettings, iDelay) {
    var _that = this;
    if ( iDelay === undefined ) {
        iDelay = 250;
    }
      
    this.each( function ( i ) {
        $.fn.dataTableExt.iApiIndex = i;
        var
            $this = this,
            oTimerId = null,
            sPreviousSearch = null,
            anControl = $( 'input', _that );
          //	console.log(anControl.length + " Controls Found");
            anControl.unbind( 'keyup' ).bind( 'keyup', function() {
	            var $$this = $this;
	            var value = this.value;
	            var index = $( 'input', _that ).index($(this));
	        //    console.log("Running Keyup " +  this.value + " index " + $( 'input', _that ).index($(this))); 
	            
	            if (oTimerId != null) {
	            //	console.log("clear timer...");
	            	 window.clearTimeout(oTimerId);
	            }
	            
                oTimerId = window.setTimeout(function() {
                    $.fn.dataTableExt.iApiIndex = i;
                	// console.log("running filter " + value + " index " + $( 'input', _that ).index($(this)));
                    _that.fnFilter( value,  index);
                 //   console.log("done running filter");
                }, iDelay);
        });
          
        return this;
    } );
    return this;
};

Viewing all articles
Browse latest Browse all 83169

Trending Articles



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