We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Disable Copy and Paste for Cells

I have a requirement where i do not wish user to copy data from certain Columns and only allow data to be copied from certain Columns. 

How do i restrict copy functionality for columns in Grid


6 Replies

HK Harini Kannan Syncfusion Team May 9, 2023 07:16 AM UTC

Hi PDev,


 Greetings from Syncfusion support,


By reviewing your query to disable the edit option for a particular column field, you can use the allowEditing property set to false. Copy and paste will be disabled, and you have mentioned that to disable Copy and Paste for Cells If allowEditing property is set to false. The copied value could not be paste in cells. We have provided a API link and documentation for your reference.


API Link:  https://ej2.syncfusion.com/angular/documentation/api/grid/column/#allowediting


Documentation : https://ej2.syncfusion.com/angular/documentation/grid/editing/edit#disable-editing-for-particular-column


Kindly get back to us if you have any concern.


Regards,

Harini K



PD PDev May 9, 2023 08:44 AM UTC

Thanks. But this will not work.


My grid has 2 sections. left side has dropdowns while right side has timeline where user need to make an update on values i.e. number,decimals etc. that is where they need functionality to copy and paste. but left side of the grid is editable but past function should not work. 


I was hoping you can show me how to use below code ? 

BeforePasteEventArgs


beforePaste:this.onChildBeforePaste.bind(this)


onChildBeforePaste(args:BeforePasteEventArgs){
console.log(args);
}


PD PDev May 17, 2023 02:44 PM UTC

Any update on this issue? We have noticed another issue.  while dragging cell value to other cell. if cell has decimals, while dragging values i.e. 0.50 will paste 0.00 instead. 


Please look into this as well. 


Awaiting reply



HS Hemanthkumar S Syncfusion Team May 22, 2023 11:45 AM UTC

Hi PDev,


Before we proceed with providing a solution to your query, we would like to request some additional information to better understand the issue you are facing. Please provide us with the following details:


  1. Could you please provide a detailed description of the issue you are currently facing and what your expected scenario is? This will help us better understand the problem and provide an appropriate solution.
  2. Could you please clarify if you are using normal edit mode or dialog edit mode or batch edit mode in the Grid?
  3. Could you kindly share the complete code for rendering the Grid? Having the full code will allow us to review the implementation and potentially identify any issues or suggest improvements.
  4. Please provide the version of the Syncfusion package that you are using. This information is crucial for reproducing the issue accurately and ensuring that the solution aligns with the specific package version.
  5. If possible, sharing a video demonstration of the issue would greatly assist us in better understanding your query. It would allow us to visualize the problem and provide more precise guidance or suggestions.
  6. If you have a reproducible sample that showcases the issue, please share it with us. Having a sample will enable us to directly analyze and validate the problem, which can lead to a faster resolution.


We appreciate your cooperation in providing us with the requested information, as it will help us provide a more effective solution to your query.


Regards,

Hemanth Kumar S



PD PDev May 29, 2023 09:14 AM UTC

  1. Could you please provide a detailed description of the issue you are currently facing and what your expected scenario is? This will help us better understand the problem and provide an appropriate solution. --> I have grid with 2 sets of columns, one is timeline columns e.g. Jan-23, Feb-23,Mar-23 etc. and other set if Name,Address etc. I want to restrict copy/paste on Name,Address Columns, but it should be editable when user double click on the cell. but it should not allow copy and past. on the other hand timeline columns should be editable and should allow copy/past
  2. Could you please clarify if you are using normal edit mode or dialog edit mode or batch edit mode in the Grid? --> Batch
  3. Could you kindly share the complete code for rendering the Grid? Having the full code will allow us to review the implementation and potentially identify any issues or suggest improvements. --> unfortunately it will not be possible instead if you can create a sample with 2 columns, where 1 columns allows EDIT & COPY PASTE while 2nd column only ALLOWS EDIT and NOT COPY and PASTE
  4. Please provide the version of the Syncfusion package that you are using. This information is crucial for reproducing the issue accurately and ensuring that the solution aligns with the specific package version. --> 
  5. "@syncfusion/ej2-angular-grids": "^19.3.53",
  6. If possible, sharing a video demonstration of the issue would greatly assist us in better understanding your query. It would allow us to visualize the problem and provide more precise guidance or suggestions.
  7. If you have a reproducible sample that showcases the issue, please share it with us. Having a sample will enable us to directly analyze and validate the problem, which can lead to a faster resolution.

I think 5 &6 are bit difficult to say. can you not provide simple sample with 2 columns where 1 column is editable and allows copy and paste while 2nd column will only allow edit and does not allow copy and paste


HK Harini Kannan Syncfusion Team June 1, 2023 09:08 AM UTC

Hi PDev,

 

Query: Disable Copy and Paste for Cells

 

As per your query we achieved your requirement by providing a two columns (customerID) and (shipCountry) columns. In customerID column we allowed to edit, copy and paste . In shipCountry column It allows to edit and it doesnot allows to copy and paste. We have used beforePaste() event to prevent paste in the specific column and In cellSelection() event we enable the args.cancel true. We have attached code snippet and sample for your reference.

 

Code Snippet:

beforePaste(args: { column: { field: string }; cancel: boolean }) {

   if (args.column.field === 'ShipCountry') {

     args.cancel = true;

   }

 }

 

cellSelecting(args) {

   if ((this.grid.getRowInfo(args.currentCell).column as any).field === 'ShipCountry' ) {

     args.cancel = true;

   }

 }

 

Sample: https://stackblitz.com/edit/angular-nsza63-p4xzzo?file=src%2Fapp.component.ts

 

Regards,

Harini K



Loader.
Up arrow icon