monomer-hagrid-0.3.0.0: A datagrid widget for the Monomer library.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Monomer.Hagrid

Description

A datagrid widget for the Monomer UI library.

Synopsis

Types

data HagridCfg s e Source #

Configuration options for Hagrid widgets.

Instances

Instances details
Monoid (HagridCfg s e) Source # 
Instance details

Defined in Monomer.Hagrid

Methods

mempty :: HagridCfg s e #

mappend :: HagridCfg s e -> HagridCfg s e -> HagridCfg s e #

mconcat :: [HagridCfg s e] -> HagridCfg s e #

Semigroup (HagridCfg s e) Source # 
Instance details

Defined in Monomer.Hagrid

Methods

(<>) :: HagridCfg s e -> HagridCfg s e -> HagridCfg s e #

sconcat :: NonEmpty (HagridCfg s e) -> HagridCfg s e #

stimes :: Integral b => b -> HagridCfg s e -> HagridCfg s e #

Default (HagridCfg s e) Source # 
Instance details

Defined in Monomer.Hagrid

Methods

def :: HagridCfg s e #

data Column e a Source #

A column definition.

Constructors

Column 

Fields

  • name :: Text

    The name of the column, displayed in the column header.

  • widget :: ColumnWidget e a

    Creates the widget for each cell in the column.

  • footerWidget :: ColumnFooterWidget e a

    Creates the widget for the column footer, if any.

  • align :: ColumnAlign

    How to align the widget within each cell in the column.

  • sortKey :: ColumnSortKey a

    Determines if and how the column can be sorted by clicking the column header.

  • initialWidth :: Int

    The initial width of the column, in pixels. The user can then change the width by dragging the edge of the column header.

  • minWidth :: Int

    The minimum allowed width of the column, in pixels.

  • paddingW :: Double

    The padding to the left and right of the widget in each cell of the column, in pixels (the default is 10).

  • paddingH :: Double

    The padding above and below the widget in each cell in the column, in pixels (the default is 10).

  • resizeHandler :: Maybe (Int -> e)

    An optional event to emit when a user has finished resizing the column. The function receives the new width in pixels.

  • sortHandler :: Maybe (SortDirection -> e)

    An optional event to emit when a user has sorted the column by clicking the header. The function receives the new sort direction.

data ColumnAlign Source #

How to align the widget within each cell of a column.

Instances

Instances details
Show ColumnAlign Source # 
Instance details

Defined in Monomer.Hagrid

Eq ColumnAlign Source # 
Instance details

Defined in Monomer.Hagrid

data ColumnWidget e a Source #

How to create the widget that displays each cell in a column.

Constructors

LabelWidget (Int -> a -> Text)

Create a label widget.. The function receives the original item index (i.e. not the index in the sorted list) and the item itself.

CustomWidget (forall s. WidgetModel s => Int -> a -> WidgetNode s e)

Create a widget of arbitrary type. The function receives the original item index (i.e. not the index in the sorted list) and the item itself.

data ColumnFooterWidget e a Source #

How to create the footer widget for a column.

Constructors

NoFooterWidget

No footer widget for this column.

CustomFooterWidget (forall s. WidgetModel s => Seq (ItemWithIndex a) -> WidgetNode s e)

Create a footer widget. The function receives the items in their current sort order, and also along with each item it's original (unsorted) index.

data ColumnSortKey a Source #

Whether a column can be sorted by the user clicking the column header, and if so, how.

Constructors

DontSort

Means that a column can't be sorted.

forall b.Ord b => SortWith (a -> b)

Means that a column can be sorted, using the specified sort key function.

data SortDirection Source #

Whether a column is being sorted in ascending or descending order.

Instances

Instances details
Show SortDirection Source # 
Instance details

Defined in Monomer.Hagrid

Eq SortDirection Source # 
Instance details

Defined in Monomer.Hagrid

type ItemWithIndex a = (a, Int) Source #

A item in the grid, with its row index.

type ScrollToRowCallback a Source #

Arguments

 = Seq (ItemWithIndex a)

The items in the grid, in the originally provided order, along with each item's index in the current grid order.

-> Maybe Int

The row to scroll to, as an index into the sorted items (e.g. 0 is always the first row in the grid, regardless of the current order). Nothing will cancel the scroll.

Picks an item to scroll to, based on the sorted or original grid contents.

Configuration options

estimatedItemHeight :: Double -> HagridCfg s e Source #

Configures the estimated item height. This should be the average row height you expect in your grid (including padding). This is used to show scrollbar size and position when there are lots of rows and so not all the rows have been "inflated" into widgets. More accurate values will improve performance and scrollbar position accuracy.

The default value is 40, which is roughly the height of a single line of text with the default column padding (10).

initialSort Source #

Arguments

:: Int

The initial sort column (zero-indexed, out of bounds values will have no effect).

-> SortDirection

The initial sort direction.

-> HagridCfg s e 

Configures the initial sort column and direction.

Hagrid constructors

hagrid Source #

Arguments

:: forall a s e. (CompositeModel a, WidgetModel s, WidgetEvent e) 
=> [Column e a]

The definitions for each column in the grid.

-> Seq a

The items for each row in the grid.

-> WidgetNode s e 

Creates a hagrid widget, using the default configuration.

hagrid_ Source #

Arguments

:: forall a s e. (CompositeModel a, WidgetModel s, WidgetEvent e) 
=> [HagridCfg s e] 
-> [Column e a]

The definitions for each column in the grid.

-> Seq a

The items for each row in the grid.

-> WidgetNode s e 

Creates a hagrid widget, using the given configuration.

Column Constructors

textColumn Source #

Arguments

:: Text

Name of the column, to display in the header.

-> (a -> Text)

Called with the item for each row to get the text to display for that row.

-> Column e a 

Creates a column that displays a text value, and is sortable by the text.

showOrdColumn Source #

Arguments

:: (Show b, Ord b) 
=> Text

Name of the column, to display in the header.

-> (a -> b)

Called with the item for each row to get the value to display (via show) and sort by.

-> Column e a 

Creates a column that displays the result of calling show on a value, and is sortable by the value.

widgetColumn Source #

Arguments

:: Text

Name of the column, to display in the header.

-> (forall s. Int -> a -> WidgetNode s e)

Called with the (original, not sorted) index and the item for each row to get the widget to display for that row.

-> Column e a 

Creates a column that displays the a custom widget in each cell.

Messages

scrollToRow Source #

Arguments

:: forall s e sp ep a. (Typeable a, Typeable e) 
=> WidgetKey

The widget to target.

-> ScrollToRowCallback a

Determines which row to scroll to.

-> EventResponse s e sp ep 

Sends a message to the targeted hagrid widget, that causes the widget to scroll such that a specified row becomes visible.

Note that this is inherently dynamically typed. If the type of the callback does not match the type of the targeted hagrid widget then the message will be ignored.