DataTables logo DataTables

via Ad Packs
DataTables Column Filter add-on for the data table
  • jocapcjocapc
    Posts: 43
    Hi,

    I have created one add-on for the DataTable that might be usefull for you. I called it Column Filter plugin and there I have added lot of individual column filtering functionalities found on the data tables site/forum.
    I think that if you are using individual column filtering this plugin can help you because it is realy easy to use it. As an example, to apply default filtering you will need just a following line of code:

    $("#dataTableId").dataTable().columnFilter();
    

    This code adds simple text filters in the footer of the table.
    There are lot of configuration parameters you can send to the add-on please see more exmples on the http://jquery-datatables-column-filter.googlecode.com/svn/trunk/index.html .

    Regards,
    Jovan
  • nm_alexnm_alex
    Posts: 26
    Thumbs up! Both!
  • 0a0d0s00a0d0s0
    Posts: 7
    This is really great. : )

    Is there a way to position the select box filter anywhere on the page? Or is it limited to just the footer or the head area, i.e. sPlaceHolder: "head:before"

    Thanks!
  • emeraldemerald
    Posts: 5
    hi,
    thumps up for this great plugin, indeed very useful :)
  • jocapcjocapc
    Posts: 43
    Hi,

    Currently filters can be placed only in the header/footer. I'm trying to find some generic way to place them anywhere on the page but I still cannot find some generic-enough way popup, existing div, autogenerated controls or attaching handler to the existing elements, etc). At them moment if you need realy custom filtering you will need to use something like a http://www.datatables.net/examples/api/regex.html.

    I'm glad that you like it.

    Thanks,
    Jovan
  • AmeenaAmeena
    Posts: 10
    I would like to use fixed footer with this. Is it possible?
  • jocapcjocapc
    Posts: 43
    Hi,

    I tried it once with a FixedHeader and it worked fine, but I can not guarantee the it will work in all cases.

    Regards,
    Jovan
  • AmeenaAmeena
    Posts: 10
    I tried with following initialization but it doesn't work. Please help me
    var oTable =   $('#table1').dataTable({
    		"bFilter": false,
    		"sScrollY": "400px",       
    		"bPaginate": false,
    		"bInfo" : false
    					} );
    new FixedHeader( oTable, { "bottom": true } ); 
    oTable.columnFilter({aoColumns: [ null,{ type:  "text"},{ type: "select", values: [ 'Power on Server']  },
    		          				     { type: "select", values: [ 'Complete','Failed','Incomplete'] },
    		        				     { type:  "text"},{ type: "text" },{ type: "text" }
    		        				]
    
    		        		});
    
  • jocapcjocapc
    Posts: 43
    Hi,

    You can see similar example on the http://jquery-datatables-column-filter.googlecode.com/svn/trunk/fixedHeader.html. I'm using the latest version of the FixedHeader from the original site. Only change I have made is commenting out scroll parameter because I got an error from FixedHeader ("FixedHeader 2 is not supported with DataTables' scrolling mode at this time"). However everything else works fine (FF, Chrome and IE).

    Regards,
    Jovan
  • AmeenaAmeena
    Posts: 10
    Thanks for this. I would like to use "bFilter": false and "bInfo" : false along with this plugin add on and fixed header. Also i would like to add an option All to display all select options. Could you please help me on this?
    I used following initialization which doesn't work.
    var oTable = $('#table1').dataTable({
    		"bFilter": false,
    		"bInfo" : false
    					} ).columnFilter({aoColumns: [ null,{ type:  "text"},{ type: "select", values: [ 'All Tasks','Power on Server']  },
    	                                                        			{ type: "select", values: [ 'All Status','Complete','Failed','Incomplete'] },
    	                                                      			{ type:  "text"},{ type:  "text"},{ type:  "text"}
    	                                                  		]
    
    	                                          		});
    	                  				new FixedHeader( oTable, { "bottom": true } );
    	
  • jocapcjocapc
    Posts: 43
    Hi Ameena,

    Could you please post this problem on the http://code.google.com/p/jquery-datatables-column-filter/issues/list this is issue list for the column filter add-in? Also, I would need error description, online example or even zipped example so I can try it.

    Thanks,
    Jovan
  • AmeenaAmeena
    Posts: 10
    Thanks Jovan,

    This works with sDom feature. Could you please help me to get sScrollY working along with this plugin. .I'm not sure why sScrollY aotuomatically adds a horizontal scrollbar too in the table while using this plugin. Please help me.
    I'm using following initialization
    var oTable = $('#table1').dataTable({"sDom": '<"top"i>rt<"bottom"lp><"clear">'
    		,"bInfo": false,"bPaginate": false,"bAutoWidth": false,"sScrollY":"400px"
    		}).columnFilter({aoColumns: [ null,{ type:  "text"},{ type: "select", values: [ 'All Tasks','Power on Server']  },
    	                            	                                                        			{ type: "select", values: [ 'All Status','Complete','Failed','Incomplete'] },
    	                            		                                                      			{ type:  "text"},{ type:  "text"},{ type:  "text"}
    	                            		                                                  		]
    
    	                            		                                          		});
    	
    	new FixedHeader( oTable, { "bottom": true } );
  • jocapcjocapc
    Posts: 43
    Hi,

    Current column filter is not 100% compatible with dataTables. It does not work with scroll feature see http://code.google.com/p/jquery-datatables-column-filter/issues/detail?id=6 , and it does not save the state into the cookie. These are not minor fixes and I will try to fix them in the next releases.
    Currently if you need filtering functionality with scrolling you will need to implement custom solution probably adjust the http://www.datatables.net/release-datatables/examples/api/multi_filter.html example.

    Regards,
    Jovan
  • Hi,
    When I place 2 tables on the page and start filtering first one it takes action on the second one. How can I fix this? It's very important.

    Thanks,
    Mateusz
  • anaganag
    Posts: 19
    Hi is it possible to re-position the filter select menu within a div on the page if so would you be able to show in a jsfiddle?

    Thanks
  • sprockettsprockett
    Posts: 12
    hi there, i have multiple tables on the same page.

    For some reason, all the filters get applied on the last table only (ie. if i edit the filter input box for the first table, the last table gets filtered instead of the first table).

    Which part of the code should I be editing to fix this?

    thanks!
  • allanallan
    Posts: 15,555
    Hi sprockett,

    How are you initialising your tables? If you are doing something like $("table").dataTable().columnFilter(); then it might be that you need to change it to something like this:

    $("table").each( function () {
      $(this).dataTable().columnFilter();
    } );
    

    The reason for this is that DataTables does not return a jQuery object, so the idea of chaining jQuery methods isn't 100% valid for DataTables.

    Allan
  • sprockettsprockett
    Posts: 12
    Hi Allan,

    Thanks for your reply... I am explicitly initialising the tables via a function:
    function config_data(id){
       var oTable;
       oTable = $('#'+id).dataTable( {
          "oLanguage": {
             "sSearch": "Search all columns:"
          },
          "sDom": 'RfClrtip',
          "bJQueryUI": true,
          "sPaginationType": "full_numbers",
          "aoColumns": fields,
          "bAutoWidth": false,
          "bInfo": true
    
          oTable.columnFilter({
             aoColumns:  fieldsfilter //fieldsfilter is an earlier defined array of column filter options for each column 
          })
    
    
       } );
    }
    

    This appears to be correct?

    Thanks!
  • allanallan
    Posts: 15,555
    Almost - it looks to me that you would be getting a JS syntax error if you used that (have a look at the Firebug / Inspector console). Try this:

    function config_data(id){
       var oTable = $('#'+id).dataTable( {
          "oLanguage": {
             "sSearch": "Search all columns:"
          },
          "sDom": 'RfClrtip',
          "bJQueryUI": true,
          "sPaginationType": "full_numbers",
          "aoColumns": fields,
          "bAutoWidth": false,
          "bInfo": true
       } );
    
          oTable.columnFilter({
             aoColumns:  fieldsfilter //fieldsfilter is an earlier defined array of column filter options for each column 
          });
    }
    
  • mihir786mihir786
    Posts: 3
    Hi ,

    I have used it in Form as well as in table header.

    It is working perfectly fine, But the problem is it doesn't help to search SPECIAL Character like ($,+,). I also made changes to existing JS file to make exact filter the reason was i wanted to be exact search.

    I am using dropdownlist as filter option.

    Could any one help me on this?
  • vannkornvannkorn
    Posts: 4
    Dear all,

    I am using a custom filter by using external form, like in this link:
    http://jquery-datatables-column-filter.googlecode.com/svn/trunk/external.html
    However, I can't create my custom filter field even I try adding similar code to the index.html page

    here is my additional filter column:
    <div id="renderingEngineFilter" class="filterOption"></div>
    				<div id="browserFilter" class="filterOption"></div>
    				<div id="platformsFilter" class="filterOption"></div>
    				<div id="engineVersionFilter" class="filterOption range"></div>
    				<div id="cssGradeFilter" class="filterOption"></div>
    				<div id="customFilter"></div> <!-- this one -->

    and I add it to my jQuery function like this:

     $(document).ready( function () {
    				$('#example').dataTable({
    					"bJQueryUI": true,
    					"sPaginationType": "full_numbers"
    				})
    					.columnFilter({aoColumns:[
    						{ type:"select", sSelector: "#renderingEngineFilter" },
    						{ sSelector: "#browserFilter" },
    						{ sSelector: "#platformsFilter" },
    						{ type:"number-range", sSelector: "#engineVersionFilter" },
    						{ type:"select", values : ["A", "B", "C", "X"], sSelector: "#cssGradeFilter" },
    						{ type:"select", values : ["vannkorn", "ravy", "rayuth"], sSelector: "#customFilter"}    //here is where I add it
    						]}
    					);
    			} );

    Unfortunately, It does not show this custom field. Please help.
  • Ameena said:
    I tried with following initialization but it doesn't work. Please help me

    Hello Everyone

    First of all sorry for my english.

    I want to share you a solution for the issue that Aveena was facing some time ago since I was have the same issue recently:

    You need to open the jquery.datatables.columnFilter.js file and add the following line after line 233:

      $.fn.columnFilter = function (options) {
    	    oTable = this;
               var TableWrapper= $('#'+oTable.attr('id') + '_wrapper');
    

    Then the following line:
      var sFilterRow = 'tfoot tr';
    

    need to be changed to the following:
      var sFilterRow = '.dataTables_scrollFoot tfoot tr';
    


    and Finally the following code:
      $(sFilterRow + " th", oTable).each(function (index) {
    

    must be changed to the following:
      $(sFilterRow + ' th', TableWrapper).each(function (index) {
    

    The reason of this changes is when the datatable have scrolling enabled. Internally datatables create one Wrapper Div called <TableID>_Wrapper and inside three more divs: One for the table Header, another for the data (the original table) and finally one for the footer. The oTable variable gets the information from the second table (data table), but we want to put our textboxes inside the datatables footer (third div). That's the reason of making the TableWrapper variable.

    I add in the sFilterRow the .dataTables_scrollFoot class because that's a class inside the footer table and I cannot found any other ID.

    I want to let you know that this only applies for datatables with scrolling enabled. This will broke if you have datatables with scrolling disabled and enabled.

    I want to request an authorization from Jovan if he can let me make some changes to the columnsfilter plugin addressing this issues.

    finally I want to thank you to the datatables team for developing this great plugin as well as Jovan for developing this great datatables tool.



    Regards

    Phoenixzero
  • BSWSBSWS
    Posts: 1
    The "date-range" column filter type doesn't work if the data contained in the cells of that column is in date with time format(mm/dd/yyyy hh:min:sec). Is there a way to make it work?! Thx.
  • I have looked and looked, please help! I need to be able to set a class for the columnfilters individually. My first column filter needs to be 100px, my second 200px; etc. I see comments to use css, but nothing about how to add the class to each filter?
  • ChrissyC said: I have looked and looked, please help! I need to be able to set a class for the columnfilters individually. My first column filter needs to be 100px, my second 200px; etc. I see comments to use css, but nothing about how to add the class to each filter?

    Hi ChrissyC

    Actually to set a default width on your filter you need to insert the code inside the javascript file (there's no CSS integrated with the columnfilters plugin). According to your post it looks like you're using the text filter so you need to look for this code:

    function fnCreateInput(regex, smart, bIsNumber) {
            var sCSSClass = "text_filter";
            if (bIsNumber)
                sCSSClass = "number_filter";
            var input = $('<input type="text" class="search_init ' + sCSSClass + '" value="' + label + '"/>');
    

    and change it to:
    function fnCreateInput(regex, smart, bIsNumber) {
            var sCSSClass = "text_filter";
            if (bIsNumber)
                sCSSClass = "number_filter";
            var input = $('<input type="text" class="search_init ' + sCSSClass + '" value="' + label + ' style="width:100px" />');
    

    you can also change/create the text_filter css class.

    Hope this helps

    Phoenixzero
  • ravishravish
    Posts: 10
    Hi I am facing the same Issue with fixed Column .

    var temp=$('#example').dataTable({

    "sScrollX": "100%",
    "sScrollY": "400",
    "bScrollCollapse": true

    });
    new FixedColumns(temp);
    temp.columnFilter({ sPlaceHolder: "head:after",
    aoColumns: [
    { type: "select", values: [ '1', '10', '15'] },
    { type: "text" },
    { type: "number-range" }
    ]
    });
    Using this in Fixed Column my Filter is not Visible and in non Fixed Column After one Search Filter is not visible pl guide .
  • This looks great! What I would really love is a filter like this that allowed you to filter by exclusion. Like the existing list filter shown at http://jquery-datatables-column-filter.googlecode.com/svn/trunk/index.html, but with the option to de-select options to not show, rather than selection options to filter by. Similar to what you get when you create column filters in Excel

    Has anyone ever done something similar with this plug-in?

    Really enjoying working with Datatables and the plug-ins people are creating. Good stuff!
  • NaterNater
    Posts: 1
    I am running into a problem when using this add on with server side processing, any time the table is redrawn I get an error saying oSettings is null. When I remove the .columnFilter code it works perfect. has anyone run into this problem?
    $('#EobTable').dataTable({
                        "bProcessing": true,
                        "bServerSide": true,
                        "sAjaxSource": "ListHandler.ashx",
                        "sServerMethod": "POST",
                        "fnServerData": function (sSource, aoData, fnCallback, oSettings) {
                            oSettings.jqXHR = $.ajax({
                                "dataType": 'json',
                                "type": 'POST',
                                "url": sSource,
                                "data": aoData,
                                "success": fnCallback
                                
                            });
                        }
                    }).columnFilter({
                        sPlaceHolder: "head:before",
                        aoColumns: [null, null, null, null, null, { type: "date-range", sRangeFormat: "Between {from} and {to} dates" }]
                    });
    
  • sreejithsreejith
    Posts: 2
    Hi all,

    I am using columnFilter add on for column-wise filtering and I ran into a small problem, Where I couldn't set size for select and text search. Is there any way I could set the size for the same?

    Thanks
  • Hi guys,

    I am facing an issue where if I use:

    sPlaceHolder: "head:before"
    

    or

    sPlaceHolder: "head:after"
    

    the filters appear inside the header row overwriting the contents of the header.

    The issue with that is if I use drop-downs - type: "select" - then at times, in addition to applying the filter, the table also gets sorted which is not the intention.

    Please advise.

    Best Regards,

    Ashish.
  • Has there been any fixes/workarounds for the special character bug?
  • smckeesmckee
    Posts: 3
    I'm having a problem with hidden columns and the filters getting out of whack. I've seen several generalized discussions about problems with column filtering and hidden columns but none relating specifically to using this plug-in. I have a working example of this at:

    http://live.datatables.net/abated/3/edit#source

    If you set the visibility of the second column to false then the filters for all following columns are off by one.

    Is there a setting that I'm missing? I need to be able to randomly turn on and off various columns depending on what page the table is being displayed on.

    Any ideas?
  • allanallan
    Posts: 15,555
    I think this issue might be the one you are seeing: http://code.google.com/p/jquery-datatables-column-filter/issues/detail?id=88 - which is specifically for that plug-in.

    Allan
  • Gl3nnGl3nn
    Posts: 5
    Hi

    I'm using DataTables with the columnFilter add-on and I was wondering if there is a way i can preset a date-range?

    My table contains events, I want to show only upcoming events so I want to set the lower date-range to current date.

                })
                        .columnFilter({
                    aoColumns: [
                        {type: "text"},
                        {type: "date-range"},  // I want to set this lower value to current date !
                        {type: "select"}
                    ]
                });
    

    Thanks

    Glenn
  • metrangiametrangia
    Posts: 2
    I have a table with 8 columns, but I want to filter on just the first 2 columns. Rather than having two input boxes (one for each column being filtered), I'd like to have one input box that filters both columns. This would be similar to the default behavior, which is one input box that filters all columns, except I want to filter on just 2 columns, not all of them. Has anybody done this? Thanks.
  • smckeesmckee
    Posts: 3
    Allan:

    I'm sorry I missed your response, yes that was the exact solution, thanks!

    Shawn

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Support

Get useful and friendly help straight from the source.

In this Discussion