DataTables example Locale based number display

DataTables has a built in number rendering type that can help to display numbers in a format your end users are familiar and comfortable with. For example, in many parts of the world . is used as a thousands separator, while in other parts , is used. The number renderer can automatically determine the correct display for your end users and display them as such.

The DataTable.render.number helper can take no arguments at all for fully automatic display, or up to five parameters for finer grained control. In this example the thousands and decimal separator (first two parameters) are defined as null to let DataTables determine what to use, zero decimal places and a prefix of $.

See the renderers documentation for full details about the renderers available in DataTables.

NamePositionOfficeAgeStart dateSalary
Tiger NixonSystem ArchitectEdinburgh612011-04-25320800
Garrett WintersAccountantTokyo632011-07-25170750
Ashton CoxJunior Technical AuthorSan Francisco662009-01-1286000
Cedric KellySenior Javascript DeveloperEdinburgh222012-03-29433060
Airi SatouAccountantTokyo332008-11-28162700
Brielle WilliamsonIntegration SpecialistNew York612012-12-02372000
Herrod ChandlerSales AssistantSan Francisco592012-08-06137500
Rhona DavidsonIntegration SpecialistTokyo552010-10-14327900
Colleen HurstJavascript DeveloperSan Francisco392009-09-15205500
Sonya FrostSoftware EngineerEdinburgh232008-12-13103600
Jena GainesOffice ManagerLondon302008-12-1990560
Quinn FlynnSupport LeadEdinburgh222013-03-03342000
Charde MarshallRegional DirectorSan Francisco362008-10-16470600
Haley KennedySenior Marketing DesignerLondon432012-12-18313500
Tatyana FitzpatrickRegional DirectorLondon192010-03-17385750
Michael SilvaMarketing DesignerLondon662012-11-27198500
Paul ByrdChief Financial Officer (CFO)New York642010-06-09725000
Gloria LittleSystems AdministratorNew York592009-04-10237500
Bradley GreerSoftware EngineerLondon412012-10-13132000
Dai RiosPersonnel LeadEdinburgh352012-09-26217500
Jenette CaldwellDevelopment LeadNew York302011-09-03345000
Yuri BerryChief Marketing Officer (CMO)New York402009-06-25675000
Caesar VancePre-Sales SupportNew York212011-12-12106450
Doris WilderSales AssistantSydney232010-09-2085600
Angelica RamosChief Executive Officer (CEO)London472009-10-091200000
Gavin JoyceDeveloperEdinburgh422010-12-2292575
Jennifer ChangRegional DirectorSingapore282010-11-14357650
Brenden WagnerSoftware EngineerSan Francisco282011-06-07206850
Fiona GreenChief Operating Officer (COO)San Francisco482010-03-11850000
Shou ItouRegional MarketingTokyo202011-08-14163000
Michelle HouseIntegration SpecialistSydney372011-06-0295400
Suki BurksDeveloperLondon532009-10-22114500
Prescott BartlettTechnical AuthorLondon272011-05-07145000
Gavin CortezTeam LeaderSan Francisco222008-10-26235500
Martena MccrayPost-Sales supportEdinburgh462011-03-09324050
Unity ButlerMarketing DesignerSan Francisco472009-12-0985675
Howard HatfieldOffice ManagerSan Francisco512008-12-16164500
Hope FuentesSecretarySan Francisco412010-02-12109850
Vivian HarrellFinancial ControllerSan Francisco622009-02-14452500
Timothy MooneyOffice ManagerLondon372008-12-11136200
Jackson BradshawDirectorNew York652008-09-26645750
Olivia LiangSupport EngineerSingapore642011-02-03234500
Bruno NashSoftware EngineerLondon382011-05-03163500
Sakura YamamotoSupport EngineerTokyo372009-08-19139575
Thor WaltonDeveloperNew York612013-08-1198540
Finn CamachoSupport EngineerSan Francisco472009-07-0787500
Serge BaldwinData CoordinatorSingapore642012-04-09138575
Zenaida FrankSoftware EngineerNew York632010-01-04125250
Zorita SerranoSoftware EngineerSan Francisco562012-06-01115000
Jennifer AcostaJunior Javascript DeveloperEdinburgh432013-02-0175650
Cara StevensSales AssistantNew York462011-12-06145600
Hermione ButlerRegional DirectorLondon472011-03-21356250
Lael GreerSystems AdministratorLondon212009-02-27103500
Jonas AlexanderDeveloperSan Francisco302010-07-1486500
Shad DeckerRegional DirectorEdinburgh512008-11-13183000
Michael BruceJavascript DeveloperSingapore292011-06-27183000
Donna SniderCustomer SupportNew York272011-01-25112000
NamePositionOfficeAgeStart dateSalary

The Javascript shown below is used to initialise the table shown in this example:

$('#example').DataTable({ columnDefs: [ { target: 4, render: DataTable.render.date() }, { target: 5, render: DataTable.render.number(null, null, 0, '$') } ] });
new DataTable('#example', { columnDefs: [ { target: 4, render: DataTable.render.date() }, { target: 5, render: DataTable.render.number(null, null, 0, '$') } ] });

In addition to the above code, the following Javascript library files are loaded for use in this example:

The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:

This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The additional CSS used is shown below:

The following CSS library files are loaded for use in this example to provide the styling of the table:

This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is loaded.

The script used to perform the server-side processing for this table is shown below. Please note that this is just an example script using PHP. Server-side processing scripts can be written in any language, using the protocol described in the DataTables documentation.