Table

An example of a simple data table

Show
entries
First Name Last Name GPA
Raeann Emard 3.16
Augustine Lakin 2.18
Berry Olson 0.55
Lourie Rau 0.63
Arnold Yundt 0.3
Shiloh Lesch 1.22
Kristy Kessler 0.55
Courtney Leannon 3.81
Cecille Schmitt 2.09
Serafina Daniel 4.24

Displaying 1 to 10 of 100

  • / 10

app/components/student_table_component.rb

class StudentTableComponent < ViewComponent::Base
  def columns
    [
      {
        header: "First Name",
        accessor: :first_name
      },
      {
        header: "Last Name",
        accessor: :last_name
      },
      {
        header: "GPA",
        accessor: ->(model) { model.gpa.round(2) },
        column: :gpa,
        type: :input
      }
    ]
  end
end