Our blazing fast Grid component built with pure JavaScript


Post by Mercury »

From what I understand the cellEdit feature is enabled by default. When turning it off I do not see an option to copy cell-content. Yet I would say that this is a valid case. We are using a grid just for display purposes (just Read, no C_UD). Of course we do not want the users to think: "Hey, we can change the cell-content, but where can I save my changes...?" So we turned cellEdit off. The only option I see at this point is a custom cellMenu item with a copy-content option. But I feel like this is something that should be available out-of-the-box.

What are your thoughts on this scenario?
Many thanks for your assistance!


Post by mats »

You mean you want to copy the textual content to the native clipboard? You can easily implement this yourself:

copyToClipboard(text) {
        let success = true;
        const textArea = document.createElement('textarea');

    textArea.value = text;
    textArea.style.height = textArea.style.width = 0;
    document.body.appendChild(textArea);

    textArea.select();
    try {
        document.execCommand('copy');
    }
    catch (e) {
        success = false;
    }
    textArea.remove();

    return success;
}

And just add your own menu option as described in this guide https://bryntum.com/docs/grid/#Grid/guides/customization/contextmenu.md

Tired of debugging javascript errors in web applications? Try our powerful error logging service RootCause


Post by Mercury »

Works for me. Thank a lot, Mats.


Post Reply