How can I get the IDs of selected items in the Content Manager from a Strapi plugin?
I tried using useCMEditViewDataManager from "@strapi/helper-plugin"
but there is no luck.
System Information
- Strapi Version: 4.4.5
How can I get the IDs of selected items in the Content Manager from a Strapi plugin?
I tried using useCMEditViewDataManager from "@strapi/helper-plugin"
but there is no luck.
Isn’t the ID passed into the view I haven’t tinkered to much with the UI so I’m not to sure.
I would look at maybe some plugins that does the same thing and see how they do it ?
I’m not sure which plugin does this already. This is my actual code. I’m trying to fetch data from useCMEditViewDataManager
on button click. The button is present in the "listView", "actions"
injection zone.
I believe the selected item data will be available in the modifiedData so I’m destructuring it.
import React from "react";
import { Button } from "@strapi/design-system/Button";
import CheckCircle from "@strapi/icons/CheckCircle";
import { useCMEditViewDataManager } from "@strapi/helper-plugin";
export const MyButton = () => {
const { modifiedData } = useCMEditViewDataManager();
const handleClick = () => {
// Get the IDs of selected entries
console.log(modifiedData);
};
return (
<Button
startIcon={<CheckCircle />}
variant="success-light"
onClick={() => handleClick}
>
Action Button
</Button>
);
};
TypeError: Cannot destructure property 'modifiedData' of '(0 , g.useCMEditViewDataManager)(...)' as it is undefined.
Anybody else faced similar issue before? Or any ideas?
Try not destructure it try just log it out and you will see what’s inside of it
I was getting some errors. For now, I’m using this as a workaround.
But it’ll be really good if the Strapi Developer documentation is updated with this kind of stuff.