Skip to main content Skip to docs navigation

Selectable Rows Table Example

On this page
Stats
#callbacks:

Source

Selectable rows

NameCapitalRegionArea
ArubaOranjestadAmericas180.0
AfghanistanKabulAsia652230.0
AngolaLuandaAfrica1246700.0
AnguillaThe ValleyAmericas91.0
Åland IslandsMariehamnEurope1580.0
AlbaniaTiranaEurope28748.0
AndorraAndorra la VellaEurope468.0
United Arab EmiratesAbu DhabiAsia83600.0
ArgentinaBuenos AiresAmericas2780400.0
ArmeniaYerevanAsia29743.0
scala
val table = new Table6Base
  with Table6BootrapStyling
  with Table6SelectableRows
  with Table6StandardColumns
  with Table6Paginated {
  override type R = Country

  override def defaultPageSize: Int = 10

  val ColName = ColStr("Name", _.name.common)
  val ColCapital = ColStr("Capital", _.capital.mkString(", "))
  val ColRegion = ColStr("Region", _.region)
  val ColArea = ColStr("Area", _.area.toString)

  override def columns(): List[C] = List(
    ColName
    , ColCapital
    , ColRegion
    , ColArea
    , ColSelectRow
  )

  override def seqRowsSource: Seq[Country] = CountriesData.data
}

new Widget {
  override def widgetTitle: String = "Selectable rows"

  override def transformWidgetCardBody(elem: Elem): Elem = super.transformWidgetCardBody(elem).p_0

  override def widgetTopRight()(implicit fsc: FSContext): NodeSeq = table.clearRowSelectionBtn.btn ++ table.selectAllVisibleRowsBtn.btn.ms_2

  override def widgetContents()(implicit fsc: FSContext): NodeSeq = table.render()
}.renderWidget()