Skip to content

Commit 99604dd

Browse files
committed
Selecting Columns
Replacing the ListGuesser component in the users resource by a custom React component generated by ListGuesser
1 parent 9d32219 commit 99604dd

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

src/App.js

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
11
import React from 'react';
2-
import { Admin, Resource, ListGuesser } from 'react-admin';
2+
import { Admin, Resource } from 'react-admin';
3+
import { UserList } from './users';
34
import jsonServerProvider from 'ra-data-json-server';
45

5-
/*
6-
ListGuesser shows the following in the browser console:
7-
8-
Guessed List:
9-
10-
export const UserList = props => (
11-
<List {...props}>
12-
<Datagrid rowClick="edit">
13-
<TextField source="id" />
14-
<TextField source="name" />
15-
<TextField source="username" />
16-
<EmailField source="email" />
17-
<TextField source="address.street" />
18-
<TextField source="phone" />
19-
<TextField source="website" />
20-
<TextField source="company.name" />
21-
</Datagrid>
22-
</List>
23-
);
24-
*/
25-
266
const dataProvider = jsonServerProvider('http://jsonplaceholder.typicode.com');
277
const App = () => (
28-
<Admin dataProvider={dataProvider}>
29-
<Resource name="users" list={ListGuesser} />
30-
</Admin>
8+
<Admin dataProvider={dataProvider}>
9+
<Resource name="users" list={UserList} />
10+
</Admin>
3111
);
3212

3313
export default App;

src/users.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import { List, Datagrid, TextField, EmailField } from 'react-admin';
3+
4+
export const UserList = props => (
5+
<List {...props}>
6+
<Datagrid rowClick="edit">
7+
<TextField source="id" />
8+
<TextField source="name" />
9+
<TextField source="username" />
10+
<EmailField source="email" />
11+
<TextField source="address.street" />
12+
<TextField source="phone" />
13+
<TextField source="website" />
14+
<TextField source="company.name" />
15+
</Datagrid>
16+
</List>
17+
);
18+

0 commit comments

Comments
 (0)