Solved

Jquery DataTables simple custom filter

Posted on 2011-02-27
4
1,874 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

735 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