-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write new resources backed grid #1543
Comments
Customising rows / columnsThe previous grid has a large options / POCs below Child row render functionWe should use a children render function which is expected to return a <Grid
resource={resource({ template, initOptions: { id, data } })}
columns={columns}
>
{(columns, item, index) => {
return <Row columns={columns} item={item} index={index}>
<Cell>{item.id}</Cell>
<Cell>{item.firstName}</Cell>
<Cell>{item.lastName}</Cell>
</Row>;
}}
</Grid> A draw back of this approach is that if the user returned anything other then cells as the children of the The user would be responsible for passing on resize / editable props etc to the The above implementation could also be enhanced to receive a middleware to provide the appropriate properties for each cell for a given row. This would simplify the usage. Header row customisationIf we allow header cell customisation then we could use a similar approach to the child row renderers and create a <Grid
resource={resource({ template, initOptions: { id, data } })}
columns={columns}
>
{(columns, middleware) => {
return
<HeaderRow>
<HeaderCell {...middleware('id')}>ID</HeaderCell>
<HeaderCell {...middleware('firstName')}>First Name</HeaderCell>
<HeaderCell {...middleware('lastName')}>Surname</HeaderCell>
</HeaderRow>;
}}
</Grid> Cell only customisationDoing away with the <Grid
resource={resource({ template, initOptions: { id, data } })}
columns={columns}
>
{(columns, cell) => ([
<Cell {...cell.props('id')}>{cell.value('id')}</Cell>,
<Cell {...cell.props('firstName')}>{cell.value('firstName')}</Cell>,
<Cell {...cell.props('lastName')}>{cell.value('lastName')}</Cell>
])}
</Grid> |
Enhancement
We should write a new grid utilising resources and function based approaches as per patterns used in recent widgets.
The text was updated successfully, but these errors were encountered: