Griddle has a number of props and configuration options that can be used. This document attempts to capture all the options that can be set when using Griddle.
Griddle has a data
prop available. The data
prop is the array of data that Griddle should render. This data should be an array of JSON objects or a class. For example:
const data = [
{
"id": 0,
"name": "Mayer Leonard",
"city": "Kapowsin",
"state": "Hawaii",
"country": "United Kingdom",
"company": "Ovolo",
"favoriteNumber": 7
},
{
"id": 1,
"name": "Koch Becker",
"city": "Johnsonburg",
"state": "New Jersey",
"country": "Madagascar",
"company": "Eventage",
"favoriteNumber": 2
},
...
]
The plugins
prop is an array of Griddle plugins. Griddle plugins must follow the structure described in the plugins section.
Griddle plugins are processed in the order they are defined in the array.’
<Griddle
data={data}
plugins={[Plugin1, Plugin2, ..., Plugin6]}
/>
The events
prop is an object containing all external events that Griddle should interact with. The events that Griddle knows about by default are:
onFilter,
onSort,
onNext,
onPrevious,
onGetPage
If an event is not defined it will be a noop but if one of the default events is defined, Griddle will call it when filtering / paging / etc.
The sortProperties
prop defines the default sort options for Griddle. The sortProperties
is an array of sortProperty
objects and should look like the following:
sortProperties: [
{ id: 'one', sortAscending: true },
{ id: 'two', sortAscending: false }
];
id
of the column or property in the data objects.The styleConfig
prop defines the styling options for Griddle. This is covered in more detail in the styles section of the docs.
The styleConfig
has the shape { icons, classNames, styles}
and by default looks like:
{
icons: {
TableHeadingCell: {
sortDescendingIcon: '▼',
sortAscendingIcon: '▲'
},
},
classNames: {
Cell: 'griddle-cell',
Filter: 'griddle-filter',
Loading: 'griddle-loadingResults',
NextButton: 'griddle-next-button',
NoResults: 'griddle-noResults',
PageDropdown: 'griddle-page-select',
Pagination: 'griddle-pagination',
PreviousButton: 'griddle-previous-button',
Row: 'griddle-row',
RowDefinition: 'griddle-row-definition',
Settings: 'griddle-settings',
SettingsToggle: 'griddle-settings-toggle',
Table: 'griddle-table',
TableBody: 'griddle-table-body',
TableHeading: 'griddle-table-heading',
TableHeadingCell: 'griddle-table-heading-cell',
TableHeadingCellAscending: 'griddle-heading-ascending',
TableHeadingCellDescending: 'griddle-heading-descending',
},
styles: {
}
};
See the styles section for more information on this.
The pageProperties
prop is an object that describes what data and how much should be shown in Griddle. For example to say that Griddle is currently on page 10 of 45
and has 15 rows displayed, this would be achieved through the pageProperties object. By default, pageProperties
looks like the following:
{
currentPage: 1,
pageSize: 10
},
The pageProperties object has the following properties:
localPlugin
Any component used in Griddle can have a user-supplied component that will be used instead. This prop defines the components that Griddle should use in place of the defaults.
Components passed in on the components
prop will override both Griddle defaults and plugins. Examples of providing component overrides are available in the customization page.
All components used in Griddle exist as a container
and a view
component. Views are entirely responsible for rendering data whereas container
components interact with the store state and context.
Griddle uses its own Redux store for managing state and all of the components live in the context (this is a big part of what makes plugins work).
The default Griddle plugins are as follows:
Cell
view component needs. Expected props are:
Layout
component. See more on this in the Customization section. Expected prop(s):
Pagination
.Row
view component needs. Expected prop(s) are:
Settings
component. Expected prop(s):
SettingsToggle
component.SettingsToggle
and Settings
components.
SettingsToggle
/ Settings
) be displayedSettings
component be displayed currentlySettingsToggle
component to be renderedSettings
component to be reneredSettingsWrapper
componentSettings
that Griddle uses. Settings
consists of a series of SettingsComponents
defined by core Griddle and plugins (more documentation is coming on how to setup SettingsComponents
)
Settings
Settings
componenttable
tag and its children. Expected prop(s) are:
Table
view component needstbody
element for use in the datagrid. Expected prop(s) are:
TableBody
component needs. The visibleRowIds are obtained in this container componentthead
element. Expected prop(s) are:
TableHeading
component needs. This component is responsible for obtaining the column titles and ids from the storeth
). Expected prop(s) are:
See the customization page for more information on how to override components in Griddle.
Griddle has a single child prop, RowDefinition
which is a component in Griddle. You can import RowDefinition
alongside Griddle:
import Griddle, { RowDefinition } from 'griddle-react';
Right now this is mostly a placeholder for ColumnDefinitions but will have more properties in a later version (such as keyColumn
instead of Griddle supplying an internal key per record).
RowDefinition
takes one more many ColumnDefinition
components. The ColumnDefinition
components define characteristics of a given column. Using ColumnDefinition
components looks like:
<Griddle data={data}>
<RowDefinition>
<ColumnDefinition id="name" title="Name" />
<ColumnDefinition id="company" title="Company order={1} />
</RowDefinition>
</Griddle>
The following properties are available on ColumnDefinition
components.
data
had an array of objects that looked like { id: 1, name: 'Mayer Leonard', state: 'Ohio' }
, an id of name
would denote that the current ColumnDefinition
corresponds to the name
prop in the data.name
and you wanted to display it as Fullname
– this could be achieved through this, title
property.Griddle has a number of props and configuration options that can be used. This document attempts to capture all the options that can be set when using Griddle.
Griddle has a data
prop available. The data
prop is the array of data that Griddle should render. This data should be an array of JSON objects or a class. For example:
const data = [
{
"id": 0,
"name": "Mayer Leonard",
"city": "Kapowsin",
"state": "Hawaii",
"country": "United Kingdom",
"company": "Ovolo",
"favoriteNumber": 7
},
{
"id": 1,
"name": "Koch Becker",
"city": "Johnsonburg",
"state": "New Jersey",
"country": "Madagascar",
"company": "Eventage",
"favoriteNumber": 2
},
...
]
The plugins
prop is an array of Griddle plugins. Griddle plugins must follow the structure described in the plugins section.
Griddle plugins are processed in the order they are defined in the array.’
<Griddle
data={data}
plugins={[Plugin1, Plugin2, ..., Plugin6]}
/>
The events
prop is an object containing all external events that Griddle should interact with. The events that Griddle knows about by default are:
onFilter,
onSort,
onNext,
onPrevious,
onGetPage
If an event is not defined it will be a noop but if one of the default events is defined, Griddle will call it when filtering / paging / etc.
The sortProperties
prop defines the default sort options for Griddle. The sortProperties
is an array of sortProperty
objects and should look like the following:
sortProperties: [
{ id: 'one', sortAscending: true },
{ id: 'two', sortAscending: false }
];
id
of the column or property in the data objects.The styleConfig
prop defines the styling options for Griddle. This is covered in more detail in the styles section of the docs.
The styleConfig
has the shape { icons, classNames, styles}
and by default looks like:
{
icons: {
TableHeadingCell: {
sortDescendingIcon: '▼',
sortAscendingIcon: '▲'
},
},
classNames: {
Cell: 'griddle-cell',
Filter: 'griddle-filter',
Loading: 'griddle-loadingResults',
NextButton: 'griddle-next-button',
NoResults: 'griddle-noResults',
PageDropdown: 'griddle-page-select',
Pagination: 'griddle-pagination',
PreviousButton: 'griddle-previous-button',
Row: 'griddle-row',
RowDefinition: 'griddle-row-definition',
Settings: 'griddle-settings',
SettingsToggle: 'griddle-settings-toggle',
Table: 'griddle-table',
TableBody: 'griddle-table-body',
TableHeading: 'griddle-table-heading',
TableHeadingCell: 'griddle-table-heading-cell',
TableHeadingCellAscending: 'griddle-heading-ascending',
TableHeadingCellDescending: 'griddle-heading-descending',
},
styles: {
}
};
See the styles section for more information on this.
The pageProperties
prop is an object that describes what data and how much should be shown in Griddle. For example to say that Griddle is currently on page 10 of 45
and has 15 rows displayed, this would be achieved through the pageProperties object. By default, pageProperties
looks like the following:
{
currentPage: 1,
pageSize: 10
},
The pageProperties object has the following properties:
localPlugin
Any component used in Griddle can have a user-supplied component that will be used instead. This prop defines the components that Griddle should use in place of the defaults.
Components passed in on the components
prop will override both Griddle defaults and plugins. Examples of providing component overrides are available in the customization page.
All components used in Griddle exist as a container
and a view
component. Views are entirely responsible for rendering data whereas container
components interact with the store state and context.
Griddle uses its own Redux store for managing state and all of the components live in the context (this is a big part of what makes plugins work).
The default Griddle plugins are as follows:
Cell
view component needs. Expected props are:
Layout
component. See more on this in the Customization section. Expected prop(s):
Pagination
.Row
view component needs. Expected prop(s) are:
Settings
component. Expected prop(s):
SettingsToggle
component.SettingsToggle
and Settings
components.
SettingsToggle
/ Settings
) be displayedSettings
component be displayed currentlySettingsToggle
component to be renderedSettings
component to be reneredSettingsWrapper
componentSettings
that Griddle uses. Settings
consists of a series of SettingsComponents
defined by core Griddle and plugins (more documentation is coming on how to setup SettingsComponents
)
Settings
Settings
componenttable
tag and its children. Expected prop(s) are:
Table
view component needstbody
element for use in the datagrid. Expected prop(s) are:
TableBody
component needs. The visibleRowIds are obtained in this container componentthead
element. Expected prop(s) are:
TableHeading
component needs. This component is responsible for obtaining the column titles and ids from the storeth
). Expected prop(s) are:
See the customization page for more information on how to override components in Griddle.
Griddle has a single child prop, RowDefinition
which is a component in Griddle. You can import RowDefinition
alongside Griddle:
import Griddle, { RowDefinition } from 'griddle-react';
Right now this is mostly a placeholder for ColumnDefinitions but will have more properties in a later version (such as keyColumn
instead of Griddle supplying an internal key per record).
RowDefinition
takes one more many ColumnDefinition
components. The ColumnDefinition
components define characteristics of a given column. Using ColumnDefinition
components looks like:
<Griddle data={data}>
<RowDefinition>
<ColumnDefinition id="name" title="Name" />
<ColumnDefinition id="company" title="Company order={1} />
</RowDefinition>
</Griddle>
The following properties are available on ColumnDefinition
components.
data
had an array of objects that looked like { id: 1, name: 'Mayer Leonard', state: 'Ohio' }
, an id of name
would denote that the current ColumnDefinition
corresponds to the name
prop in the data.name
and you wanted to display it as Fullname
– this could be achieved through this, title
property.