Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2067
  • Last Modified:

Jquery DataTables simple custom filter

I'm trying to bind the following DataTables filter to a select on change event.
The onchange event fires it gets the selected value correctly but I am being defeated by the filter it does nothing to the table at present, any help appreciated

The onchange event fires the following filter function.
function onSelectChange(){
		var selected = $("#status_select option:selected").val();
		 $.fn.dataTableExt.afnFiltering.push(
					function( oSettings, aData, iDataIndex ) {
						var iColumn =6;
						var selected = $("#status_select option:selected");
						var output = selected.val();
						var iVersion = aData[6] == "-" ? 0 : aData[6]*1;
						if(slected == iVersion){return true;}
						return false;
						oTable.fnDraw();
					});
	}

Open in new window


Help appreciated.
0
bjh497
Asked:
bjh497
  • 3
1 Solution
 
BurniePCommented:
You have return false before you draw.  So oTable.fnDraw(); will not execute.

return false;
oTable.fnDraw();

Maybe ? :

oTable.fnDraw();
return false;
0
 
bjh497Author Commented:
no joy,
 I don't think I need the the oTable.fnDraw(); at all I think the filter push already does it it was just a stab in the dark earlier.
0
 
bjh497Author Commented:
oTable isn't a plugin variable has to be declared.
0
 
bjh497Author Commented:
otable was an undeclared variable.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now