diff --git a/.datatables-commit-sync b/.datatables-commit-sync index 2ddff374..c88a4cf1 100644 --- a/.datatables-commit-sync +++ b/.datatables-commit-sync @@ -1 +1 @@ -a0fac0689db72b158ac0a905a32bf9724f630c5e +dfdf6371182e92cc53cdac96a01ae9316c30702b diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index cc6c9afd..47ae52f6 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -13924,6 +13924,57 @@ } ); + /* + * Public helper functions. These aren't used internally by DataTables, or + * called by any of the options passed into DataTables, but they can be used + * externally by developers working with DataTables. They are helper functions + * to make working with DataTables a little bit easier. + */ + + /** + * Helpers for `columns.render`. + * + * The options defined here can be used with the `columns.render` initialisation + * option to provide a display renderer. The following functions are defined: + * + * * `number` - Will format numeric data (defined by `columns.data`) for + * display, retaining the original unformatted data for sorting and filtering. + * It takes 4 parameters: + * * `string` - Thousands grouping separator + * * `string` - Decimal point indicator + * * `integer` - Number of decimal points to show + * * `string` (optional) - Prefix. + * + * @example + * // Column definition using the number renderer + * { + * data: "salary", + * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' ) + * } + * + * @namespace + */ + DataTable.render = { + number: function ( thousands, decimal, precision, prefix ) { + return { + display: function ( d ) { + d = parseFloat( d ); + var intPart = parseInt( d, 10 ); + var floatPart = precision ? + (decimal+(d - intPart).toFixed( precision )).substring( 2 ): + ''; + + return (prefix||'') + + intPart.toString().replace( + /\B(?=(\d{3})+(?!\d))/g, thousands + ) + + floatPart; + } + }; + } + }; + + /* * This is really a good bit rubbish this method of exposing the internal methods * publicly... - To be fixed in 2.0 using methods on the prototype