diff --git a/examples/simple/src/posts/PostList.js b/examples/simple/src/posts/PostList.js
index dcfd0ac2ab5..9619fb74a56 100644
--- a/examples/simple/src/posts/PostList.js
+++ b/examples/simple/src/posts/PostList.js
@@ -2,12 +2,15 @@ import BookIcon from '@material-ui/icons/Book';
import Chip from '@material-ui/core/Chip';
import { withStyles } from '@material-ui/core/styles';
import React, { Children, Fragment, cloneElement } from 'react';
+import lodashGet from 'lodash/get';
+import { unparse as convertToCSV } from 'papaparse/papaparse.min';
import {
BooleanField,
BulkDeleteButton,
ChipField,
Datagrid,
DateField,
+ downloadCSV,
EditButton,
Filter,
List,
@@ -45,6 +48,14 @@ const PostFilter = props => (
);
+const exporter = (posts) => {
+ const data = posts.map(post => ({
+ ...post,
+ backlinks: lodashGet(post, 'backlinks', []).map(backlink => backlink.url),
+ }))
+ return downloadCSV(convertToCSV({ data }), 'posts');
+};
+
const styles = theme => ({
title: {
maxWidth: '20em',
@@ -96,6 +107,7 @@ const PostList = withStyles(styles)(({ classes, ...props }) => (
bulkActionButtons={}
filters={}
sort={{ field: 'published_at', order: 'DESC' }}
+ exporter={exporter}
>