I have a DataGrid anche inside it I have a child array. It's defined like:
{
id: 2,
attachments: [
{attachmentId: 1001, mandatory: true, name: "ordine"},
{attachmentId: 1002, mandatory: true, name: "ordine 2"} ]
..and so on with other fields..
}
Now I want to edit it in mode="form" and I'm not understanding how can I define a editCellComponent to allow the user to add, remove or edit for attachments.
I'm trying to create a Component to manage it with no luck.
interface Props {
data: any
}
export const AttachmentDataGrid : React.FC<Props> = ({ data } : Props) => {
const [ attachments, setAttachments ] = useState<any[]>([]);
useEffect(() => {
setAttachments(data.value);
}, []);
const onValueChanged = (e : any) => {
data.setValue(e.value);
}
const onSelectionChanged = () => {
data.component.updateDimensions();
}
return <>
<GroupItem caption="Attachment"
name="phones-container">
{ attachments.map((att, index) => {
return <GroupItem
name="attachments">
<Label text={`Attachments ${index + 1}`} />
{att.name}
<SimpleItem dataField={`attachments[${index}].name`} />
<SimpleItem dataField={`attachments[${index}].mandatory`} />
</GroupItem>
})}
<SimpleItem itemType="button"
cssClass="add-attachment-button"
onClick={() => { console.log('add-attachment') }}>
>
</SimpleItem>
</GroupItem>
</>
}
This component show me nothing T_T Did someone achieve something like this and can share code to let me understand how to control it?