Solved

Jquery DataTables simple custom filter

Posted on 2011-02-27
4
1,924 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 16

Expert Comment

by:BurnieP
ID: 34991545
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
ID: 34991598
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
ID: 34992597
oTable isn't a plugin variable has to be declared.
0
 

Author Closing Comment

by:bjh497
ID: 35034616
otable was an undeclared variable.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…
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…

695 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