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

Get image in RTE on TreeGrid click

Hello,

is there a possibility on button/grid cell click show image in ReachTextEditor? Now I am able just to show that picture as background image, but I want to have it like normal picture, but added from other source (clicking grid), not only using image tool / imageBrowser property.

Now my function looks like this (it shows picture getting from database like base64 like background in rich text editor):
 onTreeGridClick(args) {
      var img = new Image();
     img.src = args.row[0].attributes[2].ownerElement.lastElementChild.firstElementChild.currentSrc;
     $("RichTextEditor").ejRTE({
          iframeAttributes:{ style: "background: url(" + img.src + ") no-repeat;" }
     });
}

1 Reply

PO Prince Oliver Syncfusion Team May 19, 2017 08:38 AM UTC

Hi Agne,   
   
Thank you for contacting Syncfusion support.   
   
To insert an image in RTE control on button click, we can use the setHtml method and set image to RTE using image tag with src attribute set to the location of the image. Kindly refer to the following code snippet.   
 
<script> 
       function btn1click() { 
           var rteObj = $("#rteSample").data("ejRTE"); 
           rteObj.setHtml("<img src='https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png' />"); 
       } 
</script> 
 
Refer to the following link for Playground Sample: http://jsplayground.syncfusion.com/avgcko1g 
 
Regards, 
Prince 


Loader.
Up arrow icon