Regular Expresion for data for data filter
Regular Expresion for data for data filter
I have used multi Select Filter.....My Table contains third column of date for which i needed seprate logic....
My Date column contains Time as as well...but i want to filter with date only for example 2016-12-02 23:59:00.0 shows only
2016-12-02 in select option tag..
1> Problem Multiple similar date are coming in drop down since there time is different.....
2>unable code the column.search() function for this functionality
please follow the else condtion.......if you want the table plss let me know
Please Please Help...
Thanks
Here is code...
$('#priorityOrders').DataTable( {
"ordering": false,
initComplete: function () {
this.api().columns().every( function () {
var column = this;
if(this[0][0]!=2)
{
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.header()))
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
} );
}
else
{
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.header()))
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
var dat= val.split(" ");
column
.search( '^'+val+'\s' )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
var res = d.split(" ");
//console.log(res[0]);
select.append( '<option value="'+res[0]+'">'+res[0]+'</option>' )
} );
}
}
);
} });
This question has an accepted answers - jump to answer
Answers
As you say you need to use a regular expression to match the beginning of the date time string.
'^'+myValue
should do it for that specific column.Allan
thanks allan that worked ......can u please find solution for 1st problem as well
thanks allan for 1st solution ......i figured out soln for second one ...tyvm