Clear Filter - Input Boxes and Default Filters

Clear Filter - Input Boxes and Default Filters

JanuszJasinskiJanuszJasinski Posts: 36Questions: 0Answers: 0
edited February 2013 in General
I have a table with search filters for each column. One column has a default filter based on the current logged in user. I need a link/button to clear the filter and present all rows that belong to any user. I've searched high and low and thought I was close with http://datatables.net/forums/discussion/9440/reset-button-for-input-and-select/p1 but that didn't work either.

Any ideas? Thanks in advance

Here's my code:

[code]
var asInitVals = new Array();
$(document).ready(function ()
{
var oTable = $('#opencalls').dataTable({
"bAutoWidth": false,
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [7] },
{ "sType": "uk_date", "aTargets": [2] },
{ "sType": "uk_date", "aTargets": [4] },
{ "sWidth": "10px", "aTargets": [0] },
{ "sWidth": "30px", "aTargets": [2] },
{ "sWidth": "30px", "aTargets": [6] }
]
});

jQuery.fn.dataTableExt.oSort['uk_date-asc'] = function (a, b) {
var ukDatea = a.split('/');
var ukDateb = b.split('/');

var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;

return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};

jQuery.fn.dataTableExt.oSort['uk_date-desc'] = function (a, b) {
var ukDatea = a.split('/');
var ukDateb = b.split('/');

var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;

return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};

oTable.fnFilter('YoutLoginDetails',4);

$("tfoot input").keyup(function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter(this.value, $("tfoot input").index(this));
});


$("tfoot input").each(function (i) {
asInitVals[i] = this.value;
});

$("tfoot input").focus(function () {
if (this.className == "search_init") {
this.className = "";
this.value = "";
}
});

$("tfoot input").blur(function (i) {
if (this.value == "") {
this.className = "search_init";
this.value = asInitVals[$("tfoot input").index(this)];
}
});
});


[/code]

Replies

  • JanuszJasinskiJanuszJasinski Posts: 36Questions: 0Answers: 0
    In fact when using the code in the URL mentioned, I get the message that oTable is not defined
  • JanuszJasinskiJanuszJasinski Posts: 36Questions: 0Answers: 0
    Solved! I had to move around various pieces of code to make it work
This discussion has been closed.