Prevent Paste but allow Copy (bug?)

Prevent Paste but allow Copy (bug?)

ToybToyb Posts: 19Questions: 9Answers: 1

Description of problem:
When I select a cell the user needs to be able to copy the value to the clipboard but it needs to be read-only so it can't be changed. My table does this, however, if my user executes a clipboard paste it changes the cell value. How can I prevent this (bug?).

Link to test case:
To see what's happening just select a cell and paste some text.
https://datatables.net/extensions/keytable/examples/initialisation/events.html

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,441Questions: 1Answers: 10,459 Site admin
    Answer ✓

    Hi,

    Not a bug, it just wasn't a feature. It was either clipboard (copy and paste) enabled or not. However, based on your post, I've just committed a change to allow copy and paste actions to be enabled independently - e.g.:

    let table = new DataTable('#example', {
        keys: {
            clipboard: {
                copy: true,
                paste: false
            }
        }
    });
    

    That will be included in the next release.

    Allan

Sign In or Register to comment.