sli / autotable / Autotable

A datatable.

See an example of this library in action here.

Types


type alias Column msg a =
{ label : String
, key : String
, render : a -> String
, editRender : a -> Basics.Int -> Html msg
, sort : a -> String
, filter : a -> String -> Basics.Bool
, update : a -> String -> a 
}

Define a table column.


type alias Filter =
( String, String )

Represents a filter.


type alias Model msg a =
{ columns : List (Column msg a)
, data : Array a
, sorting : List Sorting
, filters : List Filter
, dragging : Maybe String
, editing : List Basics.Int
, selections : List Basics.Int
, page : Basics.Int
, options : Options
, key : String 
}

Table state.


type Msg
    = Sort String
    | Filter String String
    | DragStart String
    | DragEnd
    | DragOver String
    | Drop
    | StartEdit Basics.Int
    | FinishEdit Basics.Int
    | Edit String Basics.Int String
    | NextPage
    | PrevPage
    | SetPage Basics.Int
    | ToggleSelection Basics.Int
    | ToggleSelectAll

Table signals.


type alias Sorting =
( String, Direction )

Represents a sorting direction.

Defaults

noFiltering : a -> String -> Basics.Bool

No-op function for diabled filtering. This will also go away one day.

noSorting : a -> String

No-op function for disabled sorting. This will go away one day.

Init

init : String -> List (Column msg a) -> List a -> Options -> Model msg a

Create table state.

Update

update : Msg -> Model msg a -> Model msg a

Update table state.

View

view : Model msg a -> (Msg -> msg) -> Html msg

Render table.