Datatable horizontal scroll on top

DataTables example Scroll - horizontal and vertical

In this example you can see DataTables doing both horizontal and vertical scrolling at the same time. Note also that pagination is enabled in this example, and the scrolling accounts for this.

First nameLast namePositionOfficeAgeStart dateSalaryExtn.E-mail
TigerNixonSystem ArchitectEdinburgh612011/04/25$320,8005421
GarrettWintersAccountantTokyo632011/07/25$170,7508422
AshtonCoxJunior Technical AuthorSan Francisco662009/01/12$86,0001562
CedricKellySenior Javascript DeveloperEdinburgh222012/03/29$433,0606224
AiriSatouAccountantTokyo332008/11/28$162,7005407
BrielleWilliamsonIntegration SpecialistNew York612012/12/02$372,0004804
HerrodChandlerSales AssistantSan Francisco592012/08/06$137,5009608
RhonaDavidsonIntegration SpecialistTokyo552010/10/14$327,9006200
ColleenHurstJavascript DeveloperSan Francisco392009/09/15$205,5002360
SonyaFrostSoftware EngineerEdinburgh232008/12/13$103,6001667
JenaGainesOffice ManagerLondon302008/12/19$90,5603814
QuinnFlynnSupport LeadEdinburgh222013/03/03$342,0009497
ChardeMarshallRegional DirectorSan Francisco362008/10/16$470,6006741
HaleyKennedySenior Marketing DesignerLondon432012/12/18$313,5003597
TatyanaFitzpatrickRegional DirectorLondon192010/03/17$385,7501965
MichaelSilvaMarketing DesignerLondon662012/11/27$198,5001581
PaulByrdChief Financial Officer [CFO]New York642010/06/09$725,0003059
GloriaLittleSystems AdministratorNew York592009/04/10$237,5001721
BradleyGreerSoftware EngineerLondon412012/10/13$132,0002558
DaiRiosPersonnel LeadEdinburgh352012/09/26$217,5002290
JenetteCaldwellDevelopment LeadNew York302011/09/03$345,0001937
YuriBerryChief Marketing Officer [CMO]New York402009/06/25$675,0006154
CaesarVancePre-Sales SupportNew York212011/12/12$106,4508330
DorisWilderSales AssistantSidney232010/09/20$85,6003023
AngelicaRamosChief Executive Officer [CEO]London472009/10/09$1,200,0005797
GavinJoyceDeveloperEdinburgh422010/12/22$92,5758822
JenniferChangRegional DirectorSingapore282010/11/14$357,6509239
BrendenWagnerSoftware EngineerSan Francisco282011/06/07$206,8501314
FionaGreenChief Operating Officer [COO]San Francisco482010/03/11$850,0002947
ShouItouRegional MarketingTokyo202011/08/14$163,0008899
MichelleHouseIntegration SpecialistSidney372011/06/02$95,4002769
SukiBurksDeveloperLondon532009/10/22$114,5006832
PrescottBartlettTechnical AuthorLondon272011/05/07$145,0003606
GavinCortezTeam LeaderSan Francisco222008/10/26$235,5002860
MartenaMccrayPost-Sales supportEdinburgh462011/03/09$324,0508240
UnityButlerMarketing DesignerSan Francisco472009/12/09$85,6755384
HowardHatfieldOffice ManagerSan Francisco512008/12/16$164,5007031
HopeFuentesSecretarySan Francisco412010/02/12$109,8506318
VivianHarrellFinancial ControllerSan Francisco622009/02/14$452,5009422
TimothyMooneyOffice ManagerLondon372008/12/11$136,2007580
JacksonBradshawDirectorNew York652008/09/26$645,7501042
OliviaLiangSupport EngineerSingapore642011/02/03$234,5002120
BrunoNashSoftware EngineerLondon382011/05/03$163,5006222
SakuraYamamotoSupport EngineerTokyo372009/08/19$139,5759383
ThorWaltonDeveloperNew York612013/08/11$98,5408327
FinnCamachoSupport EngineerSan Francisco472009/07/07$87,5002927
SergeBaldwinData CoordinatorSingapore642012/04/09$138,5758352
ZenaidaFrankSoftware EngineerNew York632010/01/04$125,2507439
ZoritaSerranoSoftware EngineerSan Francisco562012/06/01$115,0004389
JenniferAcostaJunior Javascript DeveloperEdinburgh432013/02/01$75,6503431
CaraStevensSales AssistantNew York462011/12/06$145,6003990
HermioneButlerRegional DirectorLondon472011/03/21$356,2501016
LaelGreerSystems AdministratorLondon212009/02/27$103,5006733
JonasAlexanderDeveloperSan Francisco302010/07/14$86,5008196
ShadDeckerRegional DirectorEdinburgh512008/11/13$183,0006373
MichaelBruceJavascript DeveloperSingapore292011/06/27$183,0005384
DonnaSniderCustomer SupportNew York272011/01/25$112,0004226
  • Javascript
  • HTML
  • CSS
  • Ajax
  • Server-side script

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

$[document].ready[function[] { $['#example'].dataTable[ { "scrollY": 200, "scrollX": true } ]; } ];

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

  • ../../media/js/jquery.js
  • ../../media/js/jquery.dataTables.js

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:

th, td { white-space: nowrap; } div.dataTables_wrapper { width: 800px; margin: 0 auto; }

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

  • ../../media/css/jquery.dataTables.css

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.

Video liên quan

Chủ Đề