I am using multi column filter where i am having two fields from date and to date. where i want to filter on the basis of data users entered. Can any one help me in this regard
I am following this example for multi column search for above this thing.
http://live.datatables.net/etewoq/4/edit#source.
But i am getting the following error.
Data tables waring (id="example") cannot re initialize the data table
To retrieve data objects for this data table , please pass either no arguments to the function ,or set bRetrieve to true . Alternatively to destroy the old table and create a new one ,set bdestroy to true
$(document).ready(function() {
var oTable = $('#example').dataTable( {
/*displaying page numbers*/ /*"sPaginationType": "full_numbers",*/
"bFilter":true , /* set to false if you dont want to search any column */
"bRetrieve":true,
"bDestroy":true,
"bPaginate": true, /* set to false if you dont want to paginate */
"oLanguage": {
"sLengthMenu": "Display _MENU_ records per page",
"sZeroRecords": "Nothing found - sorry",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ records",
"sInfoEmpty": "Showing 0 to 0 of 0 records",
"sInfoFiltered": "(filtered from _MAX_ total records)"
},
"aoColumns": [
/* Bid Number */ null,
/* Client */ null,
/* Status */ { "bVisible": false },
/* Description `*/ { "bSortable": false},
/* Submission */ null,
/* Days left */ { "bSortable": false},
/* Decision expected Date */ null,
/* Value */ null,
/* Estimation */ { "bSortable": false},
/* Price Approval */ { "bSortable": false},
/* Bid Closure */ { "bSortable": false},
/* Order acceptance */ { "bSortable": false},
/* Bid Created Date */ { "bVisible": false }
] });
$("thead input").keyup( function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter( this.value, $("thead input").index(this) );
} );
/*
* Support functions to provide a little bit of 'user friendlyness' to the textboxes in
* the footer
*/
$("thead input").each( function (i) {
asInitVals[i] = this.value;
} );
Replies
I am following this example for multi column search for above this thing.
http://live.datatables.net/etewoq/4/edit#source.
But i am getting the following error.
Data tables waring (id="example") cannot re initialize the data table
To retrieve data objects for this data table , please pass either no arguments to the function ,or set bRetrieve to true . Alternatively to destroy the old table and create a new one ,set bdestroy to true
[CODE]
var asInitVals = new Array();
$(document).ready(function() {
var oTable = $('#example').dataTable( {
/*displaying page numbers*/ /*"sPaginationType": "full_numbers",*/
"bFilter":true , /* set to false if you dont want to search any column */
"bRetrieve":true,
"bDestroy":true,
"bPaginate": true, /* set to false if you dont want to paginate */
"oLanguage": {
"sLengthMenu": "Display _MENU_ records per page",
"sZeroRecords": "Nothing found - sorry",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ records",
"sInfoEmpty": "Showing 0 to 0 of 0 records",
"sInfoFiltered": "(filtered from _MAX_ total records)"
},
"aoColumns": [
/* Bid Number */ null,
/* Client */ null,
/* Status */ { "bVisible": false },
/* Description `*/ { "bSortable": false},
/* Submission */ null,
/* Days left */ { "bSortable": false},
/* Decision expected Date */ null,
/* Value */ null,
/* Estimation */ { "bSortable": false},
/* Price Approval */ { "bSortable": false},
/* Bid Closure */ { "bSortable": false},
/* Order acceptance */ { "bSortable": false},
/* Bid Created Date */ { "bVisible": false }
] });
$("thead input").keyup( function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter( this.value, $("thead input").index(this) );
} );
/*
* Support functions to provide a little bit of 'user friendlyness' to the textboxes in
* the footer
*/
$("thead input").each( function (i) {
asInitVals[i] = this.value;
} );
$("thead input").focus( function () {
if ( this.className == "search_init" )
{
this.className = "";
this.value = "";
}
} );
$("thead input").blur( function (i) {
if ( this.value == "" )
{
this.className = "search_init";
this.value = asInitVals[$("thead input").index(this)];
}
} );
} );
var minDateFilter;
var maxDateFilter;
$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
if ( typeof aData._date == 'undefined' ) {
aData._date = new Date(aData[1]).getTime();
}
if ( minDateFilter && !isNaN(minDateFilter) ) {
if ( aData._date < minDateFilter ) {
return false;
}
}
if ( maxDateFilter && !isNaN(maxDateFilter) ) {
if ( aData._date > maxDateFilter ) {
return false;
}
}
return true;
}
);
$(document).ready( function() {
var oTable = $('#example').dataTable( {
"bJQueryUI": true
} );
$( "#datepicker_min" ).datepicker( {
"onSelect": function(date) {
minDateFilter = new Date(date).getTime();
oTable.fnDraw();
}
} ).keyup( function () {
minDateFilter = new Date(this.value).getTime();
oTable.fnDraw();
} );
$( "#datepicker_max" ).datepicker( {
"onSelect": function(date) {
maxDateFilter = new Date(date).getTime();
oTable.fnDraw();
}
} ).keyup( function () {
maxDateFilter = new Date(this.value).getTime();
oTable.fnDraw();
} );
} );
[/CODE]
[/