Skip to content

Columns

Columns are where you define and configure what and how data will be displayed in your table.

Iridium currently supports the following columns:

Columns have a list of shared methods. Certain methods apply to the column itself, while others can configure each individual cell with that column.

Label

Sortable

The Sortable method indicate this this row should be sortable by the user.

INFO

Iridium provides default implementations for sorting for your database rows. In order to control how this column is sorted.

SortQuery

The Sort Query method allow you to define how you sort this column on a per driver basis.

go

Searchable

The Searchable method indicates that this row should be searchable by your user. If any field had the Searchable method applied, a search box will appear on your table. Searchable can be applied to as many columns as needed, and all will be searched at the same time.

Attributes

Cell Attributes

The CellAttributes method allows you to provide a list of attributes on a per cell basis. This means you can change how cells look, behave, etc, using any attribute

go
// static
TextColumn("name").
    CellAttributes(map[string]any{
        "style": "color:red", // This will apply to all cell columns. 
    })

// callback
TextColumn("name").
    CellAttributesFn(
        func (ctx CellContext) map[string]any {
            if strings.Contains(ctx.Model.Name, "Joe") {
                return map[string]any {
                    "style": "color: blue"
                }
            }
            return map[string]any {
                "style": "color: green"
            }
        }
    )

State

The State method allows to hook into the cell value before it is rendering, allow you to change it's final value. This allows you to censor content from your users, reformat the string, or completely swap out it's value.

go
// static
TextColumn("name").
    State("Joe") // This will set all the names in your table to `Joe`

// callback
TextColumn("name").
    StateFn(func(value string, ctx CellContext) string {
        return strings.ToLower(value) 
    })

Released under the MIT License.