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
  }
NameCCA2CCN3CCA3CIOCActions
ArubaAW533ABWARU
AfghanistanAF004AFGAFG
AngolaAO024AGOANG
AnguillaAI660AIA
Åland IslandsAX248ALA
AlbaniaAL008ALBALB
AndorraAD020ANDAND
United Arab EmiratesAE784AREUAE
ArgentinaAR032ARGARG
ArmeniaAM051ARMARM
American SamoaAS016ASMASA
AntarcticaAQ010ATA
French Southern and Antarctic LandsTF260ATF
Antigua and BarbudaAG028ATGANT
AustraliaAU036AUSAUS
AustriaAT040AUTAUT
AzerbaijanAZ031AZEAZE
BurundiBI108BDIBDI
BelgiumBE056BELBEL
BeninBJ204BENBEN
Burkina FasoBF854BFABUR
BangladeshBD050BGDBAN
BulgariaBG100BGRBUL
BahrainBH048BHRBRN
BahamasBS044BHSBAH
Bosnia and HerzegovinaBA070BIHBIH
Saint BarthélemyBL652BLM
Saint Helena, Ascension and Tristan da CunhaSH654SHN
BelarusBY112BLRBLR
BelizeBZ084BLZBIZ
BermudaBM060BMUBER
BoliviaBO068BOLBOL
Caribbean NetherlandsBQ535BES
BrazilBR076BRABRA
BarbadosBB052BRBBAR
BruneiBN096BRNBRU
BhutanBT064BTNBHU
Bouvet IslandBV074BVT
BotswanaBW072BWABOT
Central African RepublicCF140CAFCAF
CanadaCA124CANCAN
Cocos (Keeling) IslandsCC166CCK
SwitzerlandCH756CHESUI
ChileCL152CHLCHI
ChinaCN156CHNCHN
Ivory CoastCI384CIVCIV
CameroonCM120CMRCMR
DR CongoCD180CODCOD
Republic of the CongoCG178COGCGO
Cook IslandsCK184COKCOK
ColombiaCO170COLCOL
ComorosKM174COMCOM
Cape VerdeCV132CPVCPV
Costa RicaCR188CRICRC
CubaCU192CUBCUB
CuraçaoCW531CUW
Christmas IslandCX162CXR
Cayman IslandsKY136CYMCAY
CyprusCY196CYPCYP
CzechiaCZ203CZECZE
GermanyDE276DEUGER
DjiboutiDJ262DJIDJI
DominicaDM212DMADMA
DenmarkDK208DNKDEN
Dominican RepublicDO214DOMDOM
AlgeriaDZ012DZAALG
EcuadorEC218ECUECU
EgyptEG818EGYEGY
EritreaER232ERIERI
Western SaharaEH732ESH
SpainES724ESPESP
EstoniaEE233ESTEST
EthiopiaET231ETHETH
FinlandFI246FINFIN
FijiFJ242FJIFIJ
Falkland IslandsFK238FLK
FranceFR250FRAFRA
Faroe IslandsFO234FRO
MicronesiaFM583FSMFSM
GabonGA266GABGAB
United KingdomGB826GBRGBR
GeorgiaGE268GEOGEO
GuernseyGG831GGY
GhanaGH288GHAGHA
GibraltarGI292GIB
GuineaGN324GINGUI
GuadeloupeGP312GLP
GambiaGM270GMBGAM
Guinea-BissauGW624GNBGBS
Equatorial GuineaGQ226GNQGEQ
GreeceGR300GRCGRE
GrenadaGD308GRDGRN
GreenlandGL304GRL
GuatemalaGT320GTMGUA
French GuianaGF254GUF
GuamGU316GUMGUM
GuyanaGY328GUYGUY
Hong KongHK344HKGHKG
Heard Island and McDonald IslandsHM334HMD
HondurasHN340HNDHON