1. INCLUDE CSS AND JS FILES
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="jquery.datatables.yadcf.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<script src="jquery.dataTables.yadcf.js"></script>
2. HTML
<div id="external_filter_container_wrapper">
<label>External filter for "Numbers" column :</label>
<div id="external_filter_container"></div>
</div>
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th>Some Data</th>
<th>Numbers</th>
<th>Yes / No</th>
<th>Values</th>
<th>Tags</th>
</tr>
</thead>
<tbody>
<tr class="odd gradeX">
<td>Some Data 1</td>
<td>1000</td>
<td>Yes</td>
<td>a_value,b_value</td>
<td><span class="label lightblue">Tag1</span><span class="label lightblue">Tag2</span></td>
</tr>
<tr class="even gradeC">
<td>Some Data 2</td>
<td>22</td>
<td>No</td>
<td>b_value,c_value</td>
<td><span class="label lightblue">Tag1</span><span class="label lightblue">Tag3</span></td>
</tr>
<tr class="odd gradeA">
<td>Some Data 3</td>
<td>33</td>
<td>Yes</td>
<td>a_value</td>
<td><span class="label lightblue">Tag2</span><span class="label lightblue">Tag3</span></td>
</tr>
<tr class="even gradeA">
<td>Some Data 4</td>
<td>44</td>
<td>No</td>
<td>b_value</td>
<td><span class="label lightblue">Tag2</span></td>
</tr>
<tr class="odd gradeA">
<td>Some Data 5</td>
<td>55</td>
<td>Yes</td>
<td>a_value,b_value</td>
<td><span class="label lightblue">Tag1</span><span class="label lightblue">Tag2</span></td>
</tr>
<tr class="even gradeA">
<td>Some Data 1</td>
<td>111</td>
<td>No</td>
<td>c_value,d_value</td>
<td><span class="label lightblue">Tag2</span></td>
</tr>
<tr class="gradeA">
<td>Some Data 2</td>
<td>22</td>
<td>Yes</td>
<td>e_value,f_value</td>
<td><span class="label lightblue">Tag3</span><span class="label lightblue">Tag4</span><span class="label lightblue">Tag5</span></td>
</tr>
<tr class="gradeA">
<td>Some Data 3</td>
<td>33</td>
<td>No</td>
<td>a_value,bb_value</td>
<td><span class="label lightblue">Tag5</span></td>
</tr>
<tr class="gradeA">
<td>Some Data 4</td>
<td>44</td>
<td>Yes</td>
<td>a_value,f_value</td>
<td><span class="label lightblue">Tag4</span></td>
</tr>
<tr class="gradeA">
<td>Some Data 5</td>
<td>55</td>
<td>No</td>
<td>a_value,c_value</td>
<td><span class="label lightblue">Tag1</span><span class="label lightblue">Tag2</span></td>
</tr>
<tr class="gradeA">
<td>Some Data 1</td>
<td>10</td>
<td>Yes</td>
<td>a_value,b_value</td>
<td><span class="label lightblue">Tag1</span><span class="label lightblue">Tag3</span></td>
</tr>
<tr class="gradeA">
<td>Some Data 2</td>
<td>22</td>
<td>No</td>
<td>d_value,aa_value</td>
<td><span class="label lightblue">Tag1</span></td>
</tr>
<tr class="gradeA">
<td>Some Data 3</td>
<td>33</td>
<td>Yes</td>
<td>a_value,c_value</td>
<td><span class="label lightblue">Tag1</span><span class="label lightblue">Tag2</span></td>
</tr>
<tr class="gradeA">
<td>Some Data 4</td>
<td>44</td>
<td>No</td>
<td>a_value,bb_value</td>
<td><span class="label lightblue">Tag1</span><span class="label lightblue">Tag2</span></td>
</tr>
<tr class="gradeA">
<td>Some Data 5</td>
<td>55</td>
<td>Yes</td>
<td>c_value,e_value</td>
<td><span class="label lightblue">Tag2</span></td>
</tr>
<tr class="gradeA">
<td>Some Data 1</td>
<td>101</td>
<td>No</td>
<td>a_value,e_value</td>
<td><span class="label lightblue">Tag1</span></td>
</tr>
</tbody>
</table>
3. JAVASCRIPT
$(document).ready(function(){
$('#example').dataTable().yadcf([
{column_number : 0},
{column_number : 1, filter_type: "range_number_slider", filter_container_id: "external_filter_container"},
{column_number : 2, data: ["Yes", "No"], filter_default_label: "Select Yes/No"},
{column_number : 3, text_data_delimiter: ",", filter_type: "auto_complete"},
{column_number : 4, column_data_type: "html", html_data_type: "text", filter_default_label: "Select tag"}]);
});
4. OPTIONS
column_number: The number of the column to which the filter will be applied
Required: true
Type: String
filter_type: The type of the filter to be used in the column
Required: false
Type: String
Default value: select
Possible values: select / multi_select / auto_complete / text / date / range_number / range_number_slider / range_date
data: When the need of predefined data for filter is needed just use an array of strings ["value1","value2"....] (supported in select / multi_select / auto_complete filters) or
array of objects [{value: 'Some Data 1', label: 'One'}, {value: 'Some Data 3', label: 'Three'}] (supported in select / multi_select filters)
Required: false
Type: Array (of string or objects)
column_data_type: The type of data in column , use "html" when you have some html code in the column (support parsing of multiple elements per cell)
Required: false
Type: String
Default value: text
Possible values: text / html
text_data_delimiter: Delimiter that seperates text in table column, for example text_data_delimiter: ","
Required: false
Type: String
html_data_type: When using "html" for column_data_type argument you can choose how exactly to parse your html element/s in column , for example use "text" for the following <span class="someClass">Some text</span>
Required: false
Type: String
Default value: text
Possible values: text / value / id
filter_container_id: In case that user don't want to place the filter in column header , he can pass an id of the desired container for the column filter
Required: false
Type: String
filter_default_label: The label that will appear in the select menu filter when no value is selected from the filter
Required: false
Type: String / Array of string in case of range_number filter (first entry is for the first input and the second entry is for the second input
Default value: Select value
filter_reset_button_text: The text that will appear inside the reset button next to the select drop down (set this to false (boolean) in order to hide it from that column filter)
Required: false
Type: String / boolean
Default value: x
enable_auto_complete (this attribute is deprecated , and will become obsolete in the future , so you better start using filter_type: "auto_complete"): Turns the filter into an autocomplete input - make use of the jQuery UI Autocomplete widget (with some enhancements)
Required: false
Type: boolean
Default value: false
sort_as: Defines how the values in the filter will be sorted, alphabetically or numerically
Required: false
Type: String
Default value: alpha
Possible values: alpha / num
sort_order: Defines the order in which the values in the filter will be sorted, ascending or descending
Required: false
Type: String
Default value: asc
Possible values: asc / desc
date_format: Defines the format in which the date values are being parsed into Date object
Required: false
Type: String
Default value: mm/dd/yyyy
Possible values: mm/dd/yyyy / dd/mm/yyyy (eventually I replace yyyy into yy for jquery datepicker)
ignore_char: Tells the range_number and range_number_slide to ignore specific char while filtering (that char can used as number separator)
Required: false
Type: String
filter_match_mode: Allows to control the matching mode of the filter (supported in select / auto_complete / text filters)
Required: false
Type: String
Default value: contains
Possible values: contains / exact / startsWith
select_type: Turns the simple select element into "Chosen select" (make use of the Chosen jQuery plugin)
Required: false
Type: String
Default value: undefined
Possible values: chosen
select_type_options: This parameter will be passed "as is" the the Chosen plugin constructor
Required: false
Type: Object
Default value: {}
case_insensitive: Do case-insensitive filtering (supported in select / auto_complete / text filters)
Required: false
Type: boolean
Default value: true
filter_delay: Delay filter execution for a XXX milliseconds - filter will fire XXX milliseconds after the last keyup.
Required: false
Type: integer
Default value: undefined
5. API
exFilterColumn: Allows to trigger filter/s externally/programmatically (support ALL filter types!!!) , perfect for showing table with pre filtered columns
Arguments: table_arg: (variable of the datatable),
array of pairs: column number String/Object with from and to, filter_value (the actual string value that we want to filter by)
Usage Example: yadcf.exFilterColumn(oTable, [[0, 'Some Data 2']]); //pre filter one column
yadcf.exFilterColumn(oTable, [[0, 'Some Data 1'], [1, {from: 111, to: 1110}], [2, {from: "", to: "11/25/2014"}]]); //pre filter several columns
exGetColumnFilterVal: Allows to retreive column current filtered value (support ALL filter types!!!)
Arguments: table_arg: (variable of the datatable),
column number: column number from which we want the value
Usage Example: yadcf.exGetColumnFilterVal(oTable,1);
Return value: String (for simple filter) / Object (for range filter) with from and to properties / Array of strings for multi_select filter