Calculated Fields Form Blog

Tips and cases of use for a successful WordPress website with calculated forms.

Blog / Displaying advanced tables of records

Displaying advanced tables of records

Introducing the DataTable DS component to display advanced tables of records.


The DataTable DS control, distributed with the Developer and Platinum versions of the plugin, allows you to generate data tables with pagination, search components, sort columns, and other advanced functionalities to display the records in the recordset.



countrycapital
AbkhaziaSukhumi
AfghanistanKabul
Akrotiri and DhekeliaEpiskopi Cantonment
AlbaniaTirana
AlgeriaAlgiers
American SamoaPago Pago
AndorraAndorra la Vella
AngolaLuanda
AnguillaThe Valley
Antigua and BarbudaSt. John's
ArgentinaBuenos Aires
ArmeniaYerevan
ArubaOranjestad
Ascension IslandGeorgetown
AustraliaCanberra
AustriaVienna
AzerbaijanBaku
BahamasNassau
BahrainManama
BangladeshDhaka
BarbadosBridgetown
BelarusMinsk
BelgiumBrussels
BelizeBelmopan
BeninPorto-Novo
BermudaHamilton
BhutanThimphu
BoliviaSucre
BoliviaLa Paz
Bosnia and HerzegovinaSarajevo
BotswanaGaborone
BrazilBrasília
British Virgin IslandsRoad Town
BruneiBandar Seri Begawan
BulgariaSofia
Burkina FasoOuagadougou
BurundiBujumbura
CambodiaPhnom Penh
CameroonYaoundé
CanadaOttawa
Cape VerdePraia
Cayman IslandsGeorge Town
Central African RepublicBangui
ChadN'Djamena
ChileSantiago
ChinaBeijing
Christmas IslandFlying Fish Cove
Cocos (Keeling) IslandsWest Island
ColombiaBogotá
ComorosMoroni
Cook IslandsAvarua
Costa RicaSan José
CroatiaZagreb
CubaHavana
CuraçaoWillemstad
CyprusNicosia
Czech RepublicPrague
Côte d'IvoireYamoussoukro
Democratic Republic of the CongoKinshasa
DenmarkCopenhagen
DjiboutiDjibouti
DominicaRoseau
Dominican RepublicSanto Domingo
East Timor (Timor-Leste)Dili
Easter IslandHanga Roa
EcuadorQuito
EgyptCairo
El SalvadorSan Salvador
Equatorial GuineaMalabo
EritreaAsmara
EstoniaTallinn
EthiopiaAddis Ababa
Falkland IslandsStanley
Faroe IslandsTórshavn
Federated States of MicronesiaPalikir
FijiSuva
FinlandHelsinki
FranceParis
French GuianaCayenne
French PolynesiaPapeete
GabonLibreville
GambiaBanjul
GeorgiaTbilisi
GermanyBerlin
GhanaAccra
GibraltarGibraltar
GreeceAthens
GreenlandNuuk
GrenadaSt. George's
GuamHagåtña
GuatemalaGuatemala City
GuernseySt. Peter Port
GuineaConakry
Guinea-BissauBissau
GuyanaGeorgetown
HaitiPort-au-Prince
HondurasTegucigalpa
HungaryBudapest
IcelandReykjavík
IndiaNew Delhi
IndonesiaJakarta
IranTehran
IraqBaghdad
IrelandDublin
Isle of ManDouglas
IsraelJerusalem
ItalyRome
JamaicaKingston
JapanTokyo
JerseySt. Helier
JordanAmman
KazakhstanAstana
KenyaNairobi
KiribatiTarawa
KosovoPristina
KuwaitKuwait City
KyrgyzstanBishkek
LaosVientiane
LatviaRiga
LebanonBeirut
LesothoMaseru
LiberiaMonrovia
LibyaTripoli
LiechtensteinVaduz
LithuaniaVilnius
LuxembourgLuxembourg
MacedoniaSkopje
MadagascarAntananarivo
MalawiLilongwe
MalaysiaKuala Lumpur
MaldivesMalé
MaliBamako
MaltaValletta
Marshall IslandsMajuro
MauritaniaNouakchott
MauritiusPort Louis
MexicoMexico City
MoldovaChisinau
MonacoMonaco
MongoliaUlaanbaatar
MontenegroPodgorica
MontserratPlymouth
MoroccoRabat
MozambiqueMaputo
MyanmarNaypyidaw
Nagorno-Karabakh RepublicStepanakert
NamibiaWindhoek
NauruYaren
NepalKathmandu
NetherlandsAmsterdam
New CaledoniaNouméa
New ZealandWellington
NicaraguaManagua
NigerNiamey
NigeriaAbuja
NiueAlofi
Norfolk IslandKingston
North KoreaPyongyang
Northern CyprusNicosia
United Kingdom Northern IrelandBelfast
Northern Mariana IslandsSaipan
NorwayOslo
OmanMuscat
PakistanIslamabad
PalauNgerulmud
PalestineJerusalem
PanamaPanama City
Papua New GuineaPort Moresby
ParaguayAsunción
PeruLima
PhilippinesManila
Pitcairn IslandsAdamstown
PolandWarsaw
PortugalLisbon
Puerto RicoSan Juan
QatarDoha
Republic of China (Taiwan)Taipei
Republic of the CongoBrazzaville
RomaniaBucharest
RussiaMoscow
RwandaKigali
Saint BarthélemyGustavia
Saint HelenaJamestown
Saint Kitts and NevisBasseterre
Saint LuciaCastries
Saint MartinMarigot
Saint Pierre and MiquelonSt. Pierre
Saint Vincent and the GrenadinesKingstown
SamoaApia
San MarinoSan Marino
Saudi ArabiaRiyadh
ScotlandEdinburgh
SenegalDakar
SerbiaBelgrade
SeychellesVictoria
Sierra LeoneFreetown
SingaporeSingapore
Sint MaartenPhilipsburg
SlovakiaBratislava
SloveniaLjubljana
Solomon IslandsHoniara
SomaliaMogadishu
SomalilandHargeisa
South AfricaPretoria
South Georgia and the South Sandwich IslandsGrytviken
South KoreaSeoul
South OssetiaTskhinvali
South SudanJuba
SpainMadrid
Sri LankaSri Jayawardenapura Kotte
SudanKhartoum
SurinameParamaribo
SwazilandMbabane
SwedenStockholm
SwitzerlandBern
SyriaDamascus
São Tomé and PríncipeSão Tomé
TajikistanDushanbe
TanzaniaDodoma
ThailandBangkok
TogoLomé
TongaNukuʻalofa
TransnistriaTiraspol
Trinidad and TobagoPort of Spain
Tristan da CunhaEdinburgh of the Seven Seas
TunisiaTunis
TurkeyAnkara
TurkmenistanAshgabat
Turks and Caicos IslandsCockburn Town
TuvaluFunafuti
UgandaKampala
UkraineKiev
United Arab EmiratesAbu Dhabi
United Kingdom; EnglandLondon
United StatesWashington D.C.
United States Virgin IslandsCharlotte Amalie
UruguayMontevideo
UzbekistanTashkent
VanuatuPort Vila
Vatican CityVatican City
VenezuelaCaracas
VietnamHanoi
WalesCardiff
Wallis and FutunaMata-Utu
Western SaharaEl Aaiún
YemenSanaá
ZambiaLusaka
ZimbabweHarare


The DataTable DS control loads records from Recordset DS fields.

So, the first step will be to insert and configure a RecordSet DS field. For this post, I have inserted the Recordset DS field fieldname1 in the form, configured to read a CSV file with the list of countries and their capitals.

recordset settings

More information about the RecordSet DS fields by reading the "Using the information stored in a database or csv file in the form" post.

Once the RecordSet DS field has been inserted and configured, it is time to insert the DataTable DS control to display the records:

datatable settings

DataTable DS controls include multiple attributes to configure their components and behavior, such as Multipage to split rows into individual pages, Ordering to sort rows by column values, or Search Box to filter table rows by search terms.

I'm going to stop at the attribute "Column title|Record attribute". This attribute determines how to populate the data table. Enter a pair of values per line with the column title and the record attribute, separated by pipe symbol (|). Continuing with the post example, the table has two columns, the Country column to display the country names in the country column of the CSV file and the Capital column.

Events

The DataTable DS field triggers the cff-datatable-click custom event when its cells are clicked. The custom event receives the index of the dataset record corresponding to the clicked row.

<script>
    jQuery(document).on('cff-datatable-click', function(evt, index){
        console.log(getField('fieldname1').records[index]);
    });
</script>