e.g.
$.tablesorter.addParser({
id: "commaNum",
is: function(s) {
return /^[\d-]?[\d,]*(\.\d+)?$/.test(s);
},
format: function(s) {
return s.replace(/,/g,'');
},
type: 'numeric'
});
aquaone
(yes, you could use a more precise regex...)
On Wed, Apr 29, 2009 at 20:41, David Blomstrom <david.blomstrom@gmail.com> wrote:
I'm using jQuery's tablesorter.js to create tables with sortable rows. It works fine on both text and numerals - but only if they have no commas. For example, the following column would sort properly:218401315But this column...1,20040826,048...would sort like this:1,20026,048408Does anyone know how to fix this?I'm using PHP and MySQL to derive my data from a database table, using the following code:$Area = number_format($row["Area"]);Then I simply insert $Area in a dynamic table cell, like so...<td>$Area</td>I posted my JavaScript links below. Thanks for any tips!* * * * *<script src="http://MySite/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="http://MySite/js/tablesorter/jquery.tablesorter.js" type="text/javascript"></script>
<script language="JavaScript" type="text/JavaScript">
$(document).ready(function()
{
$("#myTable").tablesorter({ widgets: ['zebra']} );
$("#triggerMS").click(function(){
$("#menuMS").show();
return false;
});
$("#menuMS").click( function(){
$("#menuMS").hide();
return true;
});
$("#triggerReg").click(function(){
$("#menuReg").show();
return false;
});
$("#menuReg").click( function(){
$("#menuReg").hide();
return true;
});
$("#triggerKids").click(function(){
$("#menuKids").show();
return false;
});
$("#menuKids").click( function(){
$("#menuKids").hide();
return true;
});
$("#triggerLinks").click(function(){
$("#menuLinks").show();
return false;
});
$("#menuLinks").click( function(){
$("#menuLinks").hide();
return true;
});
$("#triggerBooks").click(function(){
$("#menuBooks").show();
return false;
});
$("#menuBooks").click( function(){
$("#menuBooks").hide();
return true;
});
}
);
</script>--
No comments:
Post a Comment