Skip to content

Commit 4db0332

Browse files
committed
Adding Search and Filters to the List
Post listing has full text search for body field and you can filter those results additionally via user drop down list filter you can interactively invoke via the add filter button
1 parent 4a9f13d commit 4db0332

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/posts.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
2-
import { List,
2+
import { Filter,
3+
List,
34
Datagrid,
45
TextField,
56
ReferenceField,
@@ -15,8 +16,18 @@ import { List,
1516
const PostTitle = ({ record }) => {
1617
return <span>Post {record ? `"${record.title}"` : ''}</span>;
1718
};
19+
20+
const PostFilter = (props) => (
21+
<Filter {...props}>
22+
<TextInput label="Search" source="q" alwaysOn />
23+
<ReferenceInput label="User" source="userId" reference="users" allowEmpty>
24+
<SelectInput optionText="name" />
25+
</ReferenceInput>
26+
</Filter>
27+
);
28+
1829
export const PostList = props => (
19-
<List {...props}>
30+
<List filters={<PostFilter />} {...props}>
2031
<Datagrid>
2132
<TextField source="id" />
2233
<ReferenceField source="userId" reference="users">

0 commit comments

Comments
 (0)