Solved

Jquery DataTables simple custom filter

Posted on 2011-02-27
4
1,772 Views
Last Modified: 2012-05-11
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
Comment
Question by:bjh497
  • 3
4 Comments
 
LVL 16

Expert Comment

by:BurnieP
Comment Utility
You have return false before you draw.  So oTable.fnDraw(); will not execute.

return false;
oTable.fnDraw();

Maybe ? :

oTable.fnDraw();
return false;
0
 

Author Comment

by:bjh497
Comment Utility
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
 

Accepted Solution

by:
bjh497 earned 0 total points
Comment Utility
oTable isn't a plugin variable has to be declared.
0
 

Author Closing Comment

by:bjh497
Comment Utility
otable was an undeclared variable.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now