Skip to main content Skip to docs navigation

Selectable Rows Table Example

On this page
Stats
#callbacks:

Source

Selectable rows

Name Capital Region Area
Aruba Oranjestad Americas 180.0
Afghanistan Kabul Asia 652230.0
Angola Luanda Africa 1246700.0
Anguilla The Valley Americas 91.0
Åland Islands Mariehamn Europe 1580.0
Albania Tirana Europe 28748.0
Andorra Andorra la Vella Europe 468.0
United Arab Emirates Abu Dhabi Asia 83600.0
Argentina Buenos Aires Americas 2780400.0
Armenia Yerevan Asia 29743.0
Showing 10 of 250
scala
val table = new Table6Base
  with Table6BootrapStyling
  with Table6SelectableRows
  with Table6StandardColumns
  with Table6PaginatedWithSeqDataSource {
  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()