Filter Range, but how do i make it ignore pound symbols etc
Filter Range, but how do i make it ignore pound symbols etc
Hi
Having a few issues with pound symbols.
When I add them to the table the filter cannot find the range properly.
I need to strip the pound symbols somewhere in the filter thing? kind of lost..
http://www.wearehome.com/testrane.php
[code]
/* Custom filtering function which will filter data in column four between two values */
$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
var iMin = document.getElementById('min').value * 1;
var iMax = document.getElementById('max').value * 1;
var iVersion = aData[4] == "-" ? 0 : aData[4] * 1;
if ( iMin == "" && iMax == "" )
{
return true;
}
else if ( iMin == "" && iVersion < iMax )
{
return true;
}
else if ( iMin < iVersion && "" == iMax )
{
return true;
}
else if ( iMin < iVersion && iVersion < iMax )
{
return true;
}
return false;
}
);
$(document).ready(function() {
/* Initialise datatables */
var oTable = $('#mytablex').dataTable({
"aoColumns": [
/* Engine */ null,
/* Engine */ null,
/* Browser */ null,
/* Grade */ null,
/* Monthly price */ { "sType": "currency" },
/* Full price */ { "sType": "currency" }
]
});
/* Add event listeners to the two range filtering inputs */
$('#min').change( function() { oTable.fnDraw(); } );
$('#max').change( function() { oTable.fnDraw(); } );
} );
[/code]
Having a few issues with pound symbols.
When I add them to the table the filter cannot find the range properly.
I need to strip the pound symbols somewhere in the filter thing? kind of lost..
http://www.wearehome.com/testrane.php
[code]
/* Custom filtering function which will filter data in column four between two values */
$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
var iMin = document.getElementById('min').value * 1;
var iMax = document.getElementById('max').value * 1;
var iVersion = aData[4] == "-" ? 0 : aData[4] * 1;
if ( iMin == "" && iMax == "" )
{
return true;
}
else if ( iMin == "" && iVersion < iMax )
{
return true;
}
else if ( iMin < iVersion && "" == iMax )
{
return true;
}
else if ( iMin < iVersion && iVersion < iMax )
{
return true;
}
return false;
}
);
$(document).ready(function() {
/* Initialise datatables */
var oTable = $('#mytablex').dataTable({
"aoColumns": [
/* Engine */ null,
/* Engine */ null,
/* Browser */ null,
/* Grade */ null,
/* Monthly price */ { "sType": "currency" },
/* Full price */ { "sType": "currency" }
]
});
/* Add event listeners to the two range filtering inputs */
$('#min').change( function() { oTable.fnDraw(); } );
$('#max').change( function() { oTable.fnDraw(); } );
} );
[/code]
This discussion has been closed.
Replies
.m:before
{
content: "£";
}
[/code]
Found a very dirty hack. using css selectors. Could really do with working this out so it works in all browsers
Allan
[code]
$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
var iMin = document.getElementById('min').value * 1;
var iMax = document.getElementById('max').value * 1;
var iVersion = aData[4].replace('£', '') == "-" ? 0 : aData[4].replace('£', '') * 1;
if ( iMin == "" && iMax == "" )
{
return true;
}
else if ( iMin == "" && iVersion < iMax )
{
return true;
}
else if ( iMin < iVersion && "" == iMax )
{
return true;
}
else if ( iMin < iVersion && iVersion < iMax )
{
return true;
}
return false;
}
);
[/code]
http://www.wearehome.com/testrane.php
UPDATE!
Adding a regular expression that removes both £ and "a month" strings
[code]
var patt1 = /£|a month*/ig;
var iVersion = aData[4].replace(patt1, '') == "-" ? 0 : aData[4].replace(patt1, '') * 1;
[/code]
Thanks!
Allan
this is my prototype. complete. It pulls data server side from xml and
http://www.wearehome.com/testrane.php
Next phase is pull the database from a msql database apposed from doing loads of adding up php side. Cut the load on the server !
Phase after that will be pull direct from the mysql database via ajax!
Thanks for your help Allan, had to learn all this from stratch in the last couple of weeks our web developer quit!
Im actually a graphic designer... learning jquery, php xml and so on. Been a bit of a nightmaire luckily i used actionscripting way back so its good foundation for Jquery.