Selectable cols table example
Source Code
override def renderExampleContents()(implicit fsc: FSContext): NodeSeq = {
table.render()
}
lazy val table = new Table5Base
with Table5BaseBootrapSupport
with Table5Paginated
with Table5SeqSortableDataSource
with Table5StandardColumns
with Table5Sortable
with Table5SelectableCols {
override type R = Country
override def aroundClasses()(implicit fsc: FSContext): String = super.aroundClasses() + " mb-5"
override def tableHeadStyle: Option[Table5BootrapStyles.Value] = Some(Table5BootrapStyles.Primary)
override def tableResponsive: Option[Table5BootrapResponsiveSizes.Value] = Some(Table5BootrapResponsiveSizes.ALL)
val ColActions = ColNs("Actions", implicit fsc => row => BSBtn().BtnPrimary.sm.lbl("Time?").ajax(implicit fsc => {
Js.alert(s"Time on server is: ${new Date().toGMTString}")
}).btn)
val ColName = ColStr("Name", _.name.common)
val ColCCA2 = ColStr("CCA2", _.cca2)
val ColCCN3 = ColStr("CCN3", _.ccn3)
val ColCCA3 = ColStr("CCA3", _.cca3)
val ColCIOC = ColStr("CIOC", _.cioc)
val ColStatus = ColStr("Status", _.status)
val ColUNMember = ColStr("UN Member", _.unMember.map(_.toString).getOrElse("--"))
val ColCapital = ColStr("Capital", _.capital.mkString(", "))
val ColAltSpellings = ColStr("Alt Spellings", _.altSpellings.mkString(", "))
val ColRegion = ColStr("Region", _.region)
val ColSubregion = ColStr("Subregion", _.subregion)
val ColLatLng = ColStr("LatLng", _.latlng.map(_.mkString(";")).getOrElse("--"))
val ColLandlocked = ColStr("Landlocked", _.landlocked.map(_.toString).getOrElse("--"))
val ColBorders = ColStr("Borders", _.borders.mkString(", "))
val ColArea = ColStr("Area", _.area.toString)
val ColCallingCodes = ColStr("Calling Codes", _.callingCodes.mkString(", "))
val ColFlag = ColStr("Flag", _.flag)
override def rowsSorter: PartialFunction[Table5StandardColumn[Country], Seq[Country] => Seq[Country]] = {
case ColName => _.sortBy(_.name.common)
case ColCCA2 => _.sortBy(_.cca2)
case ColCCN3 => _.sortBy(_.ccn3)
case ColCCA3 => _.sortBy(_.cca3)
case ColCIOC => _.sortBy(_.cioc)
case ColStatus => _.sortBy(_.status)
case ColUNMember => _.sortBy(_.unMember.map(_.toString).getOrElse("--"))
case ColCapital => _.sortBy(_.capital.mkString(", "))
case ColAltSpellings => _.sortBy(_.altSpellings.mkString(", "))
case ColRegion => _.sortBy(_.region)
case ColSubregion => _.sortBy(_.subregion)
case ColLatLng => _.sortBy(_.latlng.map(_.mkString(";")).getOrElse("--"))
case ColLandlocked => _.sortBy(_.landlocked.map(_.toString).getOrElse("--"))
case ColBorders => _.sortBy(_.borders.mkString(", "))
case ColArea => _.sortBy(_.area.toString)
case ColCallingCodes => _.sortBy(_.callingCodes.mkString(", "))
case ColFlag => _.sortBy(_.flag)
}
override def allColumns(): List[C] = List(
ColName
, ColCCA2
, ColCCN3
, ColCCA3
, ColCIOC
, ColActions
// , ColStatus
// , ColUNMember
// , ColCapital
// , ColAltSpellings
// , ColRegion
// , ColSubregion
// , ColLatLng
// , ColLandlocked
// , ColBorders
// , ColArea
// , ColCallingCodes
// , ColFlag
)
override def seqRowsSource: Seq[Country] = CountriesData.data
}
Name | CCA2 | CCN3 | CCA3 | CIOC | Actions |
---|---|---|---|---|---|
Aruba | AW | 533 | ABW | ARU | |
Afghanistan | AF | 004 | AFG | AFG | |
Angola | AO | 024 | AGO | ANG | |
Anguilla | AI | 660 | AIA | ||
Åland Islands | AX | 248 | ALA | ||
Albania | AL | 008 | ALB | ALB | |
Andorra | AD | 020 | AND | AND | |
United Arab Emirates | AE | 784 | ARE | UAE | |
Argentina | AR | 032 | ARG | ARG | |
Armenia | AM | 051 | ARM | ARM | |
American Samoa | AS | 016 | ASM | ASA | |
Antarctica | AQ | 010 | ATA | ||
French Southern and Antarctic Lands | TF | 260 | ATF | ||
Antigua and Barbuda | AG | 028 | ATG | ANT | |
Australia | AU | 036 | AUS | AUS | |
Austria | AT | 040 | AUT | AUT | |
Azerbaijan | AZ | 031 | AZE | AZE | |
Burundi | BI | 108 | BDI | BDI | |
Belgium | BE | 056 | BEL | BEL | |
Benin | BJ | 204 | BEN | BEN | |
Burkina Faso | BF | 854 | BFA | BUR | |
Bangladesh | BD | 050 | BGD | BAN | |
Bulgaria | BG | 100 | BGR | BUL | |
Bahrain | BH | 048 | BHR | BRN | |
Bahamas | BS | 044 | BHS | BAH | |
Bosnia and Herzegovina | BA | 070 | BIH | BIH | |
Saint Barthélemy | BL | 652 | BLM | ||
Saint Helena, Ascension and Tristan da Cunha | SH | 654 | SHN | ||
Belarus | BY | 112 | BLR | BLR | |
Belize | BZ | 084 | BLZ | BIZ | |
Bermuda | BM | 060 | BMU | BER | |
Bolivia | BO | 068 | BOL | BOL | |
Caribbean Netherlands | BQ | 535 | BES | ||
Brazil | BR | 076 | BRA | BRA | |
Barbados | BB | 052 | BRB | BAR | |
Brunei | BN | 096 | BRN | BRU | |
Bhutan | BT | 064 | BTN | BHU | |
Bouvet Island | BV | 074 | BVT | ||
Botswana | BW | 072 | BWA | BOT | |
Central African Republic | CF | 140 | CAF | CAF | |
Canada | CA | 124 | CAN | CAN | |
Cocos (Keeling) Islands | CC | 166 | CCK | ||
Switzerland | CH | 756 | CHE | SUI | |
Chile | CL | 152 | CHL | CHI | |
China | CN | 156 | CHN | CHN | |
Ivory Coast | CI | 384 | CIV | CIV | |
Cameroon | CM | 120 | CMR | CMR | |
DR Congo | CD | 180 | COD | COD | |
Republic of the Congo | CG | 178 | COG | CGO | |
Cook Islands | CK | 184 | COK | COK | |
Colombia | CO | 170 | COL | COL | |
Comoros | KM | 174 | COM | COM | |
Cape Verde | CV | 132 | CPV | CPV | |
Costa Rica | CR | 188 | CRI | CRC | |
Cuba | CU | 192 | CUB | CUB | |
Curaçao | CW | 531 | CUW | ||
Christmas Island | CX | 162 | CXR | ||
Cayman Islands | KY | 136 | CYM | CAY | |
Cyprus | CY | 196 | CYP | CYP | |
Czechia | CZ | 203 | CZE | CZE | |
Germany | DE | 276 | DEU | GER | |
Djibouti | DJ | 262 | DJI | DJI | |
Dominica | DM | 212 | DMA | DMA | |
Denmark | DK | 208 | DNK | DEN | |
Dominican Republic | DO | 214 | DOM | DOM | |
Algeria | DZ | 012 | DZA | ALG | |
Ecuador | EC | 218 | ECU | ECU | |
Egypt | EG | 818 | EGY | EGY | |
Eritrea | ER | 232 | ERI | ERI | |
Western Sahara | EH | 732 | ESH | ||
Spain | ES | 724 | ESP | ESP | |
Estonia | EE | 233 | EST | EST | |
Ethiopia | ET | 231 | ETH | ETH | |
Finland | FI | 246 | FIN | FIN | |
Fiji | FJ | 242 | FJI | FIJ | |
Falkland Islands | FK | 238 | FLK | ||
France | FR | 250 | FRA | FRA | |
Faroe Islands | FO | 234 | FRO | ||
Micronesia | FM | 583 | FSM | FSM | |
Gabon | GA | 266 | GAB | GAB | |
United Kingdom | GB | 826 | GBR | GBR | |
Georgia | GE | 268 | GEO | GEO | |
Guernsey | GG | 831 | GGY | ||
Ghana | GH | 288 | GHA | GHA | |
Gibraltar | GI | 292 | GIB | ||
Guinea | GN | 324 | GIN | GUI | |
Guadeloupe | GP | 312 | GLP | ||
Gambia | GM | 270 | GMB | GAM | |
Guinea-Bissau | GW | 624 | GNB | GBS | |
Equatorial Guinea | GQ | 226 | GNQ | GEQ | |
Greece | GR | 300 | GRC | GRE | |
Grenada | GD | 308 | GRD | GRN | |
Greenland | GL | 304 | GRL | ||
Guatemala | GT | 320 | GTM | GUA | |
French Guiana | GF | 254 | GUF | ||
Guam | GU | 316 | GUM | GUM | |
Guyana | GY | 328 | GUY | GUY | |
Hong Kong | HK | 344 | HKG | HKG | |
Heard Island and McDonald Islands | HM | 334 | HMD | ||
Honduras | HN | 340 | HND | HON |