Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A datagrid widget for the Monomer UI library.
Synopsis
- data HagridCfg s e
- data Column e a = Column {
- name :: Text
- widget :: ColumnWidget e a
- footerWidget :: ColumnFooterWidget e a
- align :: ColumnAlign
- sortKey :: ColumnSortKey a
- initialWidth :: Int
- minWidth :: Int
- paddingW :: Double
- paddingH :: Double
- resizeHandler :: Maybe (Int -> e)
- sortHandler :: Maybe (SortDirection -> e)
- data ColumnAlign
- data ColumnWidget e a
- = LabelWidget (Int -> a -> Text)
- | CustomWidget (forall s. WidgetModel s => Int -> a -> WidgetNode s e)
- data ColumnFooterWidget e a
- = NoFooterWidget
- | CustomFooterWidget (forall s. WidgetModel s => Seq (ItemWithIndex a) -> WidgetNode s e)
- data ColumnSortKey a
- data SortDirection
- type ItemWithIndex a = (a, Int)
- type ScrollToRowCallback a = Seq (ItemWithIndex a) -> Maybe Int
- estimatedItemHeight :: Double -> HagridCfg s e
- initialSort :: Int -> SortDirection -> HagridCfg s e
- hagrid :: forall a s e. (CompositeModel a, WidgetModel s, WidgetEvent e) => [Column e a] -> Seq a -> WidgetNode s e
- hagrid_ :: forall a s e. (CompositeModel a, WidgetModel s, WidgetEvent e) => [HagridCfg s e] -> [Column e a] -> Seq a -> WidgetNode s e
- textColumn :: Text -> (a -> Text) -> Column e a
- showOrdColumn :: (Show b, Ord b) => Text -> (a -> b) -> Column e a
- widgetColumn :: Text -> (forall s. Int -> a -> WidgetNode s e) -> Column e a
- scrollToRow :: forall s e sp ep a. (Typeable a, Typeable e) => WidgetKey -> ScrollToRowCallback a -> EventResponse s e sp ep
Types
Configuration options for Hagrid widgets.
A column definition.
Column | |
|
data ColumnAlign Source #
How to align the widget within each cell of a column.
Instances
Show ColumnAlign Source # | |
Defined in Monomer.Hagrid showsPrec :: Int -> ColumnAlign -> ShowS # show :: ColumnAlign -> String # showList :: [ColumnAlign] -> ShowS # | |
Eq ColumnAlign Source # | |
Defined in Monomer.Hagrid (==) :: ColumnAlign -> ColumnAlign -> Bool # (/=) :: ColumnAlign -> ColumnAlign -> Bool # |
data ColumnWidget e a Source #
How to create the widget that displays each cell in a column.
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.
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.
data SortDirection Source #
Whether a column is being sorted in ascending or descending order.
Instances
Show SortDirection Source # | |
Defined in Monomer.Hagrid showsPrec :: Int -> SortDirection -> ShowS # show :: SortDirection -> String # showList :: [SortDirection] -> ShowS # | |
Eq SortDirection Source # | |
Defined in Monomer.Hagrid (==) :: SortDirection -> SortDirection -> Bool # (/=) :: SortDirection -> SortDirection -> Bool # |
type ItemWithIndex a = (a, Int) Source #
A item in the grid, with its row index.
type ScrollToRowCallback a Source #
= 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). |
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).
:: 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
:: 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.
:: 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
:: 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.
:: (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 |
-> Column e a |
Creates a column that displays the result of calling
on a value, and is sortable by the value.show
:: 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
:: 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.