mercurymedia/elm-ag-grid/14.0.0

NOTE: the latest version is 34.0.1

AgGrid.Expression

Integration of Expressions for AgGrid. A Expression will be encoded and evaluated in javascript.

For more information take a look at https://github.com/mercurymedia/elm-ag-grid/blob/10.0.0/ag-grid-webcomponent/expression.js.

Definition

type Eval a
= Const a
| Expr Expression

Eval a can be a Cosnt a or and Expr

A `Const a` will pass the value of the type `a` directly to the `AgGrid` attribute in javascript.
A `Expr` will frist evaluated in javascript and than passed to the `AgGrid` attribute.

A Expression covers some basic operators to evaluate

At this moment this only covers very basic operations

type Literal

The Literal type represents literals for strings, ints and floats.

A Operator take expression(s) and evaluate the result in javascript.

Operators

Represents the || operator

Expression.or (Expression.value "likesElm") (Expression.value "isProgrammer")

Represents the && operator

Expression.and (Expression.value "likesElm") (Expression.value "isProgrammer")

Represents the == operator

Expression.eq (Expression.int 18) (Expression.value "age")

Represents the <= operator

Expression.lte (Expression.int 18) (Expression.value "age")

Represents the >= operator

Expression.gte (Expression.int 18) (Expression.value "age")

Represents the ! operator

Expression.not (Expression.value "isActive")

Performs the javascript Array.inclues function

Expression.includes (Expression.string "Tim") (Expression.value "names")
Where names is a list of Strings.

Literals

int : Int -> Expression

A int Literal

Expression.int 18
string : String -> Expression

A string Literal

Expression.string "Tim"
float : Float -> Expression

A string Literal

Expression.string 13.37

Row values

value : String -> Expression

The value function can be used to get a value from the data object passed in from a callback of AgGrid.

For example when it comes to disable a contextMenu entry, you can get a value from the current clicked row.

type alias Row =
    { age : Int }


columnDefs =
    [ { field = "age"
      , renderer = IntRenderer .age
      , headerName = "Age"
      , settings = AgGrid.defaultSettings
      }
    ]


contextMenu =
    [ AgGridContextMenu.contextAction
        { defaultActionAttributes
            | name = "Full age action"
            , actionName = Just "fullAgeAction"
            , disabled = Expression.Expr (Expression.lte (Expression.value "age") (Expression.int 18))
        }
    ]

Encoding

encode : (a -> Value) -> Eval a -> Value

The encode encodes a evaluation.