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

Remove hidden columns from Grid Clipboard

Hi,

How do I exclude the hidden columns and row values from the copied data when a user selects multiple rows and clicks on the ctrl-c?

I have tried deselecting the columns also from the context menu, but these still appear in the copied clipboard data. I have also tried setting the column.visible property to false, but this just removes the column header values, the row values still show.

I have had a look around the forum and can't find much about it at all, and nothing on the MVC forums. Apologies if I have missed this question being asked already.

Thanks :)


7 Replies

SI Santhosh Iruthayaraj Syncfusion Team February 14, 2023 04:16 PM UTC

Hi Rob,


Greetings from Syncfusion support.


We have validated your query “Remove hidden columns from Grid Clipboard” and set column visible property as false for a column and copied multiple rows and it’s working fine from our end. We have prepared a video sample to explain you how we tried to recreate this scenario. Please refer to the attached video.


In order to provide an accurate and effective solution, we kindly ask that you provide us with the following information:


  • Explain your requirement in detail.
  • Complete grid rendering code.
  • A Simple sample that demonstrates the issue you are experiencing.
  • A video demo of the issue.


Regards,

Santhosh Iruthayaraj



RM Rob Marsh replied to Santhosh Iruthayaraj February 14, 2023 08:13 PM UTC

Hi Santhosh,

Thanks for your reply, however, I can't seem to see the attached video that you are referring to. Am I missing it, or did you not attach it?

Thanks,

Rob



SI Santhosh Iruthayaraj Syncfusion Team February 15, 2023 05:05 AM UTC

Hi Rob,


I apologize for any inconvenience caused by the omission of the ZIP file in our previous communication. Please find attached the required ZIP file for your reference.


Regards,

Santhosh Iruthayaraj


Attachment: CopySampleVideo_45e53d7b.zip


RM Rob Marsh February 15, 2023 08:20 AM UTC

Hi Santhosh,

That method won't work as I want to hide the columns after the selection has been made, and the refreshColumns() deselects anything that was previously selected. It would also look bad on the screen as the columns would temporarily disappear, and then reappear after the copy. The flow I am after is something along the lines of:

  • User selects records in grid
  • User clicks COPY button
  • JavaScript code changes specific columns visible property to false using grid.column.visible equal to false
  • JavaScript runs grid.copy(true) to copy selected row and column header data minus any hidden columns
  • JavaScript then changes back specific column.visible property to true
We have already implemented something similar successfully on an Excel Export button as suggested here. We basically want to do something similar but copying the selected records to the clipboard rather than exporting them to excel.

Hopefully that clarifies it a bit.


SI Santhosh Iruthayaraj Syncfusion Team February 16, 2023 02:07 PM UTC

Hi Rob,


To achieve your requirement we need to use hideColumns property. But hideColumns property not working properly. We have confirmed the scenario as a bug from our side and logged a defect report for the same as “Copy not working properly when using hideColumns property”. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and will include the defect fix in our patch release scheduled to be rolled out on 8th March, 2023. We appreciate your patience until then.


You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through the below link.


Feedbackhttps://www.syncfusion.com/feedback/41195/copy-not-working-properly-when-using-hidecolumns-property


Regards,

Santhosh Iruthayaraj



SI Santhosh Iruthayaraj Syncfusion Team March 8, 2023 04:12 PM UTC

Rob,


Sorry for the inconvenience caused.

We are unable to complete this issue (“Copy not working properly when using hideColumns property”) as planned due to its complexity. We will include the fix in our upcoming patch release which is expected to be rolled out on Mar 15
th, 2023. Till then we appreciate your patience.


Feedback Link:  https://www.syncfusion.com/feedback/41195/copy-not-working-properly-when-using-hidecolumns-property



SI Santhosh Iruthayaraj Syncfusion Team March 15, 2023 01:32 PM UTC

Hi Rob,


We are glad to announce that our Essential Javascript2 patch release (v20.4.54) has been rolled out successfully and in that release, we have added the fix of “Copy not working properly when using hideColumns property” issue. So, please update your Syncfusion packages to the current version and use latest styles to get this.


Release Notes: https://ej2.syncfusion.com/javascript/documentation/release-notes/20.4.54/?type=all#grid


We thank you for your support and appreciate your patience in waiting for this release. We have also prepared a code snippet that will help achieve your requirement “Remove hidden columns from Grid Clipboard” using the beforeCopy event and hideColumns method.


[index.js]

 

function beforeCopy(args) {

    if (args.data != '') {

        let values = args.data.split('\n').length === 1 ? args.data.split('\t') : args.data.split('\n')[0].split('\t');

        if (values.length < 5) {

            grid.showColumns(['Customer Name', 'Order Date']);

            grid.selectRows(selectedRows);

            selectedRows = undefined;

        } else {

            args.cancel = true;

            selectedRows = grid.getSelectedRowIndexes();

            grid.hideColumns(['Customer Name', 'Order Date']);

            grid.selectRows(selectedRows);

            grid.copy();

        }

    }

}


Sample: https://stackblitz.com/edit/gejtyg?file=index.js


Please get in touch with us if you would require further assistance.


Regards,

Santhosh I


Loader.
Up arrow icon