Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Step 1:</strong></p> <p>extend dataTableExt.oSort with the following code: </p> <pre><code>$.extend($.fn.dataTableExt.oSort, { "numeric-pre": function(a) { a = (a === "-" || a === "") ? 0 : a.replace(/[^\d\-\.]/g, ""); return parseFloat(a); }, "numeric-asc": function(a, b) { return a - b; }, "numeric-desc": function(a, b) { return b - a; } }); </code></pre> <p><strong>Step 2:</strong> extend dataTableExt.aTypes, add comma to sValidChars variable:</p> <pre><code> # Added comma to sValidChars $.extend $.fn.dataTableExt.aTypes, [ /* * Function: - * Purpose: Check to see if a string is numeric * Returns: string:'numeric' or null * Inputs: mixed:sText - string to check */ function (sData) { /* Allow zero length strings as a number */ if (typeof sData === 'number') { return 'numeric'; } else if (typeof sData !== 'string') { return null; } var sValidFirstChars = "0123456789-"; var sValidChars = "0123456789.,"; var Char; var bDecimal = false; /* Check for a valid first char (no period and allow negatives) */ Char = sData.charAt(0); if (sValidFirstChars.indexOf(Char) == -1) { return null; } /* Check all the other characters are valid */ for (var i = 1; i &lt; sData.length; i++) { Char = sData.charAt(i); if (sValidChars.indexOf(Char) == -1) { return null; } /* Only allowed one decimal place... */ if (Char == ".") { if (bDecimal) { return null; } bDecimal = true; } } return 'numeric'; }, /* * Function: - * Purpose: Check to see if a string is actually a formatted date * Returns: string:'date' or null * Inputs: string:sText - string to check */ function (sData) { var iParse = Date.parse(sData); if ((iParse !== null &amp;&amp; !isNaN(iParse)) || (typeof sData === 'string' &amp;&amp; sData.length === 0)) { return 'date'; } return null; }, /* * Function: - * Purpose: Check to see if a string should be treated as an HTML string * Returns: string:'html' or null * Inputs: string:sText - string to check */ function (sData) { if (typeof sData === 'string' &amp;&amp; sData.indexOf('&lt;') != -1 &amp;&amp; sData.indexOf('&gt;') != -1) { return 'html'; } return null; } ]); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload