Comments (8)
You could implement this yourself by:
- Creating a custom button on the collection page to trigger your export.
BeforeList
would probably be the right place to put it. - Pulling in the
data
prop which is passed into your custom component by payload. - Converting the object into a CSV, either manually or with a library.
- Trigger a download of the CSV string you've created, using something like this approach.
This should get the job done. If you wanted to go the extra mile, this would make a great payload plugin. Something like payload-plugin-csv-export
, where you could select which collections you'd like to have this field added to. This would be much more general purpose, and keep the form builder plugin focused on the forms themselves.
from plugin-form-builder.
@IAmNatch That helped me so much. Thanks! I was simply able to whip this up in half an hour and replicate it across collections:
Here's my code:
yarn add xlsx
The component:
import { Pill } from "payload/components";
import React from "react";
import * as XLSX from "xlsx";
const ExportButton = ({ data }) => {
console.log(data);
function handleClick() {
const worksheet = XLSX.utils.json_to_sheet(data.docs);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1");
XLSX.writeFile(workbook, "Data_Export.xlsx");
}
return (
<Pill pillStyle="light" onClick={handleClick}>
Export
</Pill>
);
};
export default ExportButton;
The Custom UI for List Page:
admin: {
components: {
BeforeListTable: [ExportButton]
},
},
from plugin-form-builder.
Thanks @webmuch the solution and code snippet you provided works, also thanks to @IAmNatch for the guide
from plugin-form-builder.
sorry, haven't tried it just yet @IAmNatch. Thank you @webmuch for the snippet. I will give it a try soon and close this ticket if it resolves it :)
from plugin-form-builder.
@leikoilja does this resolve your issue?
from plugin-form-builder.
I tried this out it exports the submissions: id, formName & submissionData id. It doesn't export the contents of submissionData which is what is required. How can I get that to work?
from plugin-form-builder.
@webmuch great work 👏 This is currently planned as a Payload core feature, outlined in our public roadmap here. Feel free to leave an upvote or comment of support to prioritize that work.
from plugin-form-builder.
This plugin is now being maintained in the Packages Directory of the Payload Monorepo. This repo will soon be archived and all open issues including this one will be closed. This issue has already been added to this open discussion, though, so that it will not get lost. Please refer to that discussion for more details and to continue the conversation.
from plugin-form-builder.
Related Issues (20)
- Localization is not managed in `sendEmail` process HOT 4
- File upload field HOT 2
- Require `slug` in `Partial<Block>` type HOT 1
- add fields to form-fields HOT 5
- Is this still maintained? HOT 4
- Incorrect type definition HOT 3
- Safely fail `variables.find` HOT 1
- Add upload field HOT 1
- Add documentation about how to create form submissions + a bug HOT 1
- Need to wire up submission validations HOT 8
- Document Front End Implementation HOT 3
- How to use it with @payloadcms/next-payload ? HOT 2
- Feature request: support custom defaultColumns for Form Submissions collection HOT 1
- Feature Request: select multiple support HOT 2
- Required fields are not validated on submission HOT 3
- Error after submitting the form on Next.js HOT 6
- Field input type hidden HOT 1
- Unable to send form builder emails with resend
- Grouping fields? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plugin-form-builder.