Completed
Last Updated: 24 Feb 2021 15:45 by ADMIN
Alessandro
Created on: 05 Feb 2021 08:02
Category: Chat
Type: Feature Request
0
The url display as a link into Rad chat
Whenever I include a link in the chat, it only shows as text.  Is it possible to enable the url display as a link and allow a user to click it?
1 comment
ADMIN
Peter Milchev
Posted on: 24 Feb 2021 15:45

Hi Alessandro,

Rendering a clickable link requires a custom template as explained here:

<telerik:RadChat runat="server" ID="RadChat1">
    <ClientEvents OnLoad="OnLoad" />
</telerik:RadChat>
<script>
    var $ = $ || $telerik.$;
    function OnLoad(sender, args) {
        var Hyperlink_Card_Template = kendo.template($('#hyperlink-template').html());
        kendo.chat.registerTemplate("hyperlink", Hyperlink_Card_Template);

        var botUser = { name: "Chat bot" };

        var postArgs = $.extend(true, {}, {
            text: "some link text",
            link: "https://google.com",
            type: 'hyperlink',
            timestamp: new Date(),
            from: botUser
        });

        chat.renderMessage(postArgs, postArgs.from);
    }
</script>

<script id="hyperlink-template" type="text/x-kendo-template">
    <div class="#=styles.message#">
        <time class="#=styles.messageTime#">#= kendo.toString(kendo.parseDate(timestamp), "HH:mm:ss") #</time>
        <div class="#=styles.bubble#"><a href="#:link#">#:text#</a></div>
    </div>
</script>

 

Also, you can subscribe to the button click and navigate instead of writing the URL.

Regards,
Peter Milchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.