Open JahanzaibAbdullah opened 3 months ago
Hey @JahanzaibAbdullah and thanks for opening this issue. I am not sure if you can do this with the current way the pasting works, since only raw values are being copied to the clipBoard. To make this work we would need to identify where the data came from and where it will get pasted. The latter should not be the problem, but the former could be impossible to do. This is mainly because the source of the data could also be another table that is not a data grid.
@MBilalShafi do you have an idea if we could support this the way it works now? Or should we treat this as a feature request?
Yes, currently the clipboard copy and paste works like any other grid application such as Excel or Sheets. Technically, you could copy data from anywhere and paste into the Data Grid.
@JahanzaibAbdullah I am not sure if we have received a similar request before. May I know the motivation behind it?
If it only relates to the data type safety (e.g. you want to avoid a string being pasted in a number column), you could handle that using processRowUpdate
.
Does that fulfill your requirement by any chance?
Hi Mui/Mui-X,
I have tried using it as well but it does not fulfil my requirements,as what i need is to not let paste a copied value into the other column of different data type as there is an editable date column where i can only past copied date value from one row to another, likewise a dropdown menu for 'yes' and 'no' in which only yes or no can be pasted, no other value other than that. This is just the demo data that I shared with you earlier, later on there will be a massive amount of data in which more of the columns will be added for which we would want the same functionality.
I hope you understand my query.
Regards, Jahanzaib Malik.
On Wed, Jul 17, 2024 at 12:05 AM Bilal Shafi @.***> wrote:
Yes, currently the clipboard copy and paste works like any other grid application like Excel or Sheets. Technically, you could copy data from anywhere and paste into the Data Grid.
@JahanzaibAbdullah https://github.com/JahanzaibAbdullah I am not sure if we have received a similar request before. May I know the motivation behind it? If it only relates to the data type safety (e.g. you want to avoid a string being pasted in a number column), you could handle that using processRowUpdate https://mui.com/x/react-data-grid/clipboard/#persisting-pasted-data.
Does that fulfill your requirement by any chance?
— Reply to this email directly, view it on GitHub https://github.com/mui/mui-x/issues/13847#issuecomment-2231638560, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEPYNL6KGLMMA7Z4JYALSF3ZMVVHPAVCNFSM6AAAAABK4SXD22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZRGYZTQNJWGA . You are receiving this because you were mentioned.Message ID: @.***>
I am almost entirely sure that this is not possible atm ... It kind of relates to this issue: #13895
I just tested it in Google Sheets and there at least you can just paste any value in any cell, regardless of pre-existing values.
Yes, it's not supported at the moment. As you suggested in #13895, we would need to allow the users to pre-process the copied value to add some additional information like the colDef
object (basically some stringified JSON) and combine that with the processRowUpdate
to parse and not proceed with pasting values of other columns.
But even if we do that, it will come with some limitations, as the clipboard feature uses OS clipboard, you would not be able to paste the values copied from outside the Data Grid correctly.
I'd be in favor of adding waiting for upvotes
label to see the demand for it in the community since it might be relevant to a specific set of requirements.
What do you think @michelengelen ?
Sure , till then i can add some validations in colDef editcell to avoid this problem if possible, but i will also be looking forward to your response for this issue.
Hi @MBilalShafi , did you find any solution for this issue ?
Hey @JahanzaibAbdullah, as mentioned above, this functionality is not supported at the moment.
This issue is a waiting for 👍
feature request. Feel free to drop an upvote (👍 reaction) on the description of the issue to increase its probability of being picked up by the team as a feature.
Hey @MBilalShafi, I was going through the documentation of Datagrid and i have found the Prop in coldef to deal with this issue i was facing but that solution is not so efficient but it is fulfilling my requirements for now.
Here is how i have achieved it, in the following code, pastedValueParser is the prop that helped me in achieving my functionality.
`const validateNumeric = (value: string) => !isNaN(Number(value));
{ field: 'verifiedRADCenter', headerName: 'Verified RAD Center', minWidth: 220, flex: 0.1, display: 'flex', editable: true, pastedValueParser: (value) => { return validateNumeric(value) ? Number(value) : null; }, renderHeader: () => { return ( <> {loading ? ( <Skeleton animation="wave" variant="rounded" width={150} /> ) : ( <Typography variant="subtitle2" fontWeight={600}
Verified RAD Center )} </> ); }, renderCell: (params: any) => <>{loading ?
: params.value}</>, }, `
I want the cell color to change to light green when pasting data from one cell to another, similar to how the color changes when editing a cell.
Here is a screenshot showing the cell color change when editing:
In this screenshot, when I copy the value 52 and paste it into another cell, I want the pasted cell's color to change in the same way as the cell color changes during editing.
I want the cell color to change to light green when pasting data from one cell to another, similar to how the color changes when editing a cell.
Here is a screenshot showing the cell color change when editing:
In this screenshot, when I copy the value 52 and paste it into another cell, I want the pasted cell's color to change in the same way as the cell color changes during editing.
@mahammahmood This seems like something different from this specific issue. Could you open up a separate issue for it?
You can follow this guide on how to open one in a way for the team to understand your needs best: https://mui.com/x/introduction/support/#github
The problem in depth
Hi there,
I want to avoid copy and pasting the data from one column to another in datagrid and i am unable to do it as there is no prop to do it.
find some attached Screenshots i am sharing with you.
in the above picture you can see, different columns, and it has different data, i want to make sure that Verified RAD center data should not be pasted in anu other column and likewise for other columns as well,
i am providing you my code snippet as well,
Thank you for your support. I look forward to your prompt response.
Regards, Jahanzaib Malik
Your environment
`npx @mui/envinfo`
``` Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here. ```Search keywords: Data Grid Premium, copy paste Order ID: 91010