Example of a table with date and number comparators

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>JSM Test Page</title> <script type="text/javascript" src="lib/date.js"></script> <link rel=stylesheet type="text/css" href="../jsm-documentation.css"> <style> body { margin: 10px 0px 0px 10px; background-color:#ffffff; color: #000000; } </style> <script src="jsm.js" type="text/javascript"></script> <link rel=stylesheet type="text/css" href="css/jsm.css"> <script> //your onSaveRow Event function jsmOnSaveRow(table, rowIdx) { var message="Data: \n"; var tds = table.getTds(rowIdx); for (var tdIdx in tds) { var td = tds[tdIdx]; if (td.getMetaData('actionCell') != 'true') message=message+"Table cell is dirty: " + td.isDirty() + " and has value: " + td.getValue() + " - selectFieldValue: " + td.getMetaData("selectFieldValue") + "\n"; } alert(message); table.getRow(rowIdx).setDirty(false); } </script> </head> <body> <div id="myTableContainer"></div> <script> function sortColumnThree(table, columnIdx) { JsmDateComparator.setFormat(null); table.sort(columnIdx); table.render(); } function sortColumnFour(table, columnIdx) { JsmDateComparator.setFormat("MM@d-y"); table.sort(columnIdx); table.render(); } myTable = new JsmTable("myTableContainer", "myTable"); myTable.setHeaderRow(new JsmTr().addCell(new JsmTh("one").setAttribute("width", "300")).addCell(new JsmTh("two").setAttribute("width", "150")).addCell(new JsmTh("three").setOnClick('sortColumnThree').setAttribute("width", "150")).addCell(new JsmTh("four").setOnClick('sortColumnFour').setAttribute("width", "150"))); myTable.addComparator("two", JsmNumberComparator); myTable.addComparator("three", JsmDateComparator); myTable.addComparator("four", JsmDateComparator); myTable.addRow(new JsmTr().addCell(new JsmTd("one")).addCell(new JsmTd("1")).setMetaData("id", "1").addCell(new JsmTd("05-30-2006")).addCell(new JsmTd("05@30-2006"))); myTable.addRow(new JsmTr().addCell(new JsmTd("two")).addCell(new JsmTd("2")).setMetaData("id", "2").addCell(new JsmTd("07-08-2006")).addCell(new JsmTd("07@08-2006"))); myTable.addRow(new JsmTr().addCell(new JsmTd("three")).addCell(new JsmTd("3")).setMetaData("id", "3").addCell(new JsmTd("03-15-2004")).addCell(new JsmTd("03@15-2004"))); myTable.addRow(new JsmTr().addCell(new JsmTd("ten")).addCell(new JsmTd("10")).setMetaData("id", "4").addCell(new JsmTd("12-01-2005")).addCell(new JsmTd("12@01-2005"))); myTable.addRow(new JsmTr().addCell(new JsmTd("eleven")).addCell(new JsmTd("11")).setMetaData("id", "5").addCell(new JsmTd("11-21-2006")).addCell(new JsmTd("11@21-2006"))); myTable.sort("three"); myTable.render(); </script> </body> </html>