Datatable Formatted-num and columnFilter
Datatable Formatted-num and columnFilter
Hi!
I have a table with prices when I use formatted number, and also want to have filters (on top) but I'm affraid that do not work.
please.....Any clue? example? Thanks in advance
the inicialization code is:
jQuery.fn.dataTableExt.oSort['formatted-num-asc'] = function(a,b) {
/* Remove any formatting */
var x = a.match(/\d/) ? a.replace( /[^\d\-\.]/g, "" ) : 0;
var y = b.match(/\d/) ? b.replace( /[^\d\-\.]/g, "" ) : 0;
/* Parse and return */
return parseFloat(x) - parseFloat(y);
};
jQuery.fn.dataTableExt.oSort['formatted-num-desc'] = function(a,b) {
var x = a.match(/\d/) ? a.replace( /[^\d\-\.]/g, "" ) : 0;
var y = b.match(/\d/) ? b.replace( /[^\d\-\.]/g, "" ) : 0;
return parseFloat(y) - parseFloat(x);
};
$(document).ready(function() {
$('#example').dataTable( {
bJQueryUI: true,
"sPaginationType": "full_numbers",
"aoColumns": [
null,
{ type: "select", values: [ 'Casa -', 'Casa en privada'] },
null,
{ "sType": "formatted-num" },
null,
null,
null,
null,
null
]
.columnFilter()
});
});
the sample working (without formatting number in price ) is http://www.proin.com.mx/general-casas-renta.php
thanks!!!!!
l Rodriguez
I have a table with prices when I use formatted number, and also want to have filters (on top) but I'm affraid that do not work.
please.....Any clue? example? Thanks in advance
the inicialization code is:
jQuery.fn.dataTableExt.oSort['formatted-num-asc'] = function(a,b) {
/* Remove any formatting */
var x = a.match(/\d/) ? a.replace( /[^\d\-\.]/g, "" ) : 0;
var y = b.match(/\d/) ? b.replace( /[^\d\-\.]/g, "" ) : 0;
/* Parse and return */
return parseFloat(x) - parseFloat(y);
};
jQuery.fn.dataTableExt.oSort['formatted-num-desc'] = function(a,b) {
var x = a.match(/\d/) ? a.replace( /[^\d\-\.]/g, "" ) : 0;
var y = b.match(/\d/) ? b.replace( /[^\d\-\.]/g, "" ) : 0;
return parseFloat(y) - parseFloat(x);
};
$(document).ready(function() {
$('#example').dataTable( {
bJQueryUI: true,
"sPaginationType": "full_numbers",
"aoColumns": [
null,
{ type: "select", values: [ 'Casa -', 'Casa en privada'] },
null,
{ "sType": "formatted-num" },
null,
null,
null,
null,
null
]
.columnFilter()
});
});
the sample working (without formatting number in price ) is http://www.proin.com.mx/general-casas-renta.php
thanks!!!!!
l Rodriguez
This discussion has been closed.