locked
Allow user to copy text in GridView cell to clipboard RRS feed

  • Question

  • User-1641476077 posted

    Hi,

    I have a GridView to display some data to user. Recently users inform me that they are not able to select any text from the GridView and copy them.

    i.e they want to use the cursor to highlight the text and then copy them to their clipboard and after that they should be able to paste it somewhere else, for example notepad or ms word

    i would like to check how do i allow them to do it?

    Monday, May 21, 2018 6:48 AM

Answers

  • User-1509636757 posted

    I doubt that question describes the issue very well, if that really is happening on users' side, because GridView is made up with standard table/tr/td elements from which user can easily double click on contents of td and paste it anywhere.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 21, 2018 11:27 AM
  • User283571144 posted

    Hi bczm8703,

    As KaushaL says, the general gridview will generate the html table in the page.

    We could directly copy the table's value to the clipboard.

    Like below example:

    Have you add some other setting to prevent user copy the page elements?

    For example

    User the javascript to prevent user copy cell value.

    Like this:

    <body oncontextmenu="return false" onselectstart="return false"
          onkeydown="if ((arguments[0] || window.event).ctrlKey) return false">

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 22, 2018 7:38 AM

All replies

  • User-1509636757 posted

    I doubt that question describes the issue very well, if that really is happening on users' side, because GridView is made up with standard table/tr/td elements from which user can easily double click on contents of td and paste it anywhere.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 21, 2018 11:27 AM
  • User283571144 posted

    Hi bczm8703,

    As KaushaL says, the general gridview will generate the html table in the page.

    We could directly copy the table's value to the clipboard.

    Like below example:

    Have you add some other setting to prevent user copy the page elements?

    For example

    User the javascript to prevent user copy cell value.

    Like this:

    <body oncontextmenu="return false" onselectstart="return false"
          onkeydown="if ((arguments[0] || window.event).ctrlKey) return false">

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 22, 2018 7:38 AM
  • User-1641476077 posted

    Hi apology for the late reply. 

    Firstly thanks kaushalparik and Brando for replying to my post. was trying to debug the code the whole day. i found out the issue was due to some option setting in the nicescroll.js. 

    i am able to select text from my tables now.

    Tuesday, May 22, 2018 7:53 AM