Table

An example of a simple data table

Show
entries
First Name Last Name GPA
Nelson Kling 1.49
Wilfred Herzog 2.11
Quinn Carter 1.91
Lenora Wunsch 2.92
Sandee Pfeffer 3.1
Dallas Tillman 3.43
Cleotilde Collier 3.88
Scotty Balistreri 1.33
Louisa Terry 1.08
Wiley Thiel 1.3

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