DataTables Column Filter add-on for the data table
DataTables Column Filter add-on for the data table
jocapc
Posts: 45Questions: 0Answers: 0
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:
[code]
$("#dataTableId").dataTable().columnFilter();
[/code]
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
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:
[code]
$("#dataTableId").dataTable().columnFilter();
[/code]
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
This discussion has been closed.
Replies
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!
thumps up for this great plugin, indeed very useful :)
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
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
[code]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" }
]
});
[/code]
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
I used following initialization which doesn't work.
[code]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 } );
[/code]
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
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
[code]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 } );[/code]
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
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
Thanks
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!
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:
[code]
$("table").each( function () {
$(this).dataTable().columnFilter();
} );
[/code]
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
Thanks for your reply... I am explicitly initialising the tables via a function:
[code]
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
})
} );
}
[/code]
This appears to be correct?
Thanks!
[code]
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
});
}
[/code]
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?
http://datatables.net/forums/discussion/9559/columnfilter-works-only-on-last-datatable-when-created-in-a-function#Item_1
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:
[code]
<!-- this one -->[/code]
and I add it to my jQuery function like this:
[code] $(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
]}
);
} );[/code]
Unfortunately, It does not show this custom field. Please help.
I tried with following initialization but it doesn't work. Please help me
[/quote]
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:
[code]
$.fn.columnFilter = function (options) {
oTable = this;
var TableWrapper= $('#'+oTable.attr('id') + '_wrapper');
[/code]
Then the following line:
[code]
var sFilterRow = 'tfoot tr';
[/code]
need to be changed to the following:
[code]
var sFilterRow = '.dataTables_scrollFoot tfoot tr';
[/code]
and Finally the following code:
[code]
$(sFilterRow + " th", oTable).each(function (index) {
[/code]
must be changed to the following:
[code]
$(sFilterRow + ' th', TableWrapper).each(function (index) {
[/code]
The reason of this changes is when the datatable have scrolling enabled. Internally datatables create one Wrapper Div called _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
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:
[code]
function fnCreateInput(regex, smart, bIsNumber) {
var sCSSClass = "text_filter";
if (bIsNumber)
sCSSClass = "number_filter";
var input = $('');
[/code]
and change it to:
[code]
function fnCreateInput(regex, smart, bIsNumber) {
var sCSSClass = "text_filter";
if (bIsNumber)
sCSSClass = "number_filter";
var input = $('
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 .
Has anyone ever done something similar with this plug-in?
Really enjoying working with Datatables and the plug-ins people are creating. Good stuff!
[code]
$('#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" }]
});
[/code]
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
I am facing an issue where if I use:
[code]
sPlaceHolder: "head:before"
[/code]
or
[code]
sPlaceHolder: "head:after"
[/code]
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.