Skip to Content
avatar image
Former Member

How to get copy command after clicking on a link in sapui5?

Hi,

I am working on SAPUI5. I have json data with three text fields. If I click on a link on table, it should copy JSON data. and we can paste it anywhere. How to do this in sapui5?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 12 at 12:06 PM

    Hi,

    Below code will work for you.

    function myFunction() {
      var copyText = document.createElement("input");
      copyText.value = "Your text here";
      document.body.appendChild(copyText);
      copyText.select();
      document.execCommand("Copy");
      alert("Copied the text: " + copyText.value);
    }
    
    Add comment
    10|10000 characters needed characters exceeded

  • Apr 12 at 10:44 AM

    Hello Preety,

    Could you provide us with some more details on what you are trying to do? Do you want to display data from a JSON model in a table, copy it to some other place? It is not clear from the description what you really want to do. The SAPUI5 version and controls you are using are also useful to help you.

    Best regards,

    Désirée

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I have a table. All the data in table is fetching through json. There is one field in table called copy link. If I click on link only particular data from JSON should copy, so that if I paste somewhere, the copied JSON data should come.