Show / SimpleShowLayout Does not Render Fields When in a Grid
See original GitHub issueWhat you were expecting: When using material UI Grid in an Edit or Create page, the field contents displayed perfect. I expected the Grid to work the same way on a Show page.
What happened instead: When using the same Grid on a Show page, the fields did not display.
Steps to reproduce: Modify the demo/example https://marmelab.com/react-admin/Show.html#the-simpleshowlayout-component to include a Material UI Grid that wraps the fields.
Related code:
import Grid from '@material-ui/core/Grid';
export const PostShowx = (props) => (
<Show {...props}>
<SimpleShowLayout>
<Grid container >
<Grid item xs={6}>
<TextField source="title" />
</Grid>
<Grid item xs={6}>
<TextField source="name" />
</Grid>
</Grid>
<RichTextField source="body" />
</SimpleShowLayout>
</Show>
);
Even a simple html table seems to not render the TextFields:
export const PostShow = (props) => (
<Show {...props}>
<SimpleShowLayout>
<table>
<tr>
<td>
<TextField source="title" />
</td>
<td>
<TextField source="name" />
</td>
</tr>
</table>
<RichTextField source="body" />
</SimpleShowLayout>
</Show>
);
Note: It works just fine on an Edit page:
export const PostEdit = (props) => (
<Edit title={<PostTitle />} {...props}>
<SimpleForm>
<DisabledInput source="id" />
<Grid container >
<Grid item xs={6}>
<ReferenceInput label="User" source="userId" reference="users">
<SelectInput optionText="name" />
</ReferenceInput>
</Grid>
<Grid item xs={6}>
<TextInput source="title" />
</Grid>
</Grid>
<LongTextInput source="body" />
</SimpleForm>
</Edit>
);
Environment
- React-admin version: 2.2.0
- React version: 16.4.1
- Browser: Tried on both Firefox and Chrome
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:9 (5 by maintainers)
Top Results From Across the Web
How to organise a Show layout in React Admin using a ...
ShowLayout components from rendering the Field components inside them properly. I was hoping to be able to do something like this: <Show {......
Read more >The Show Component - React-admin - Marmelab
<Show> doesn't render any field by default - it delegates this to its children. Show layout components grab the record from the RecordContext...
Read more >React Data Grid: Rendering - AG Grid
When using AG Grid React, all of the grid's core rendering (headers, rows, cells etc) is rendered using React. AG Grid React shares...
Read more >Data Grid - Column definition - MUI X
Sometimes a column might not have a corresponding value, or you might want to render a combination of different fields. To achieve that,...
Read more >GridProps - React Data Grid Component - KendoReact API
If virtualization is enabled, the columns outside the view are not rendered. data? "null" | any[] | DataResult. Sets the data of the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Faced the same issue trying to use Grid. Simple workaround : use className 🎉
example :
<DateField source="profile.birthdate" className="ra-field-50 " />
<TextField source="profile.firstname" className="ra-field-clear ra-field-50" />
<TextField source="profile.lastname" className="ra-field-50" />
for input fields use formClassName
<TextInput source="profile.lastname" formClassName="ra-field-50" />
implement it how you like, add media queries and so on…
Hence the
Simple
in its name and why we also provide theTabbedShowLayout
andTabbedForm
components. For other cases, you’ll have to implement your own layout/form