enable/disable encode html for grid column

1 Answer 465 Views
Grid
Giuseppe
Top achievements
Rank 1
Giuseppe asked on 09 Aug 2021, 03:07 PM

Hi,

i've seen that for grid columns of jquery component it is possibile to set the encoding to true or false

so if the data i will get is like this 

hello my name is <strong> Giuseppe </strong>

i will see "hello my name is Giuseppe"

 

as of now i see "hello my name is <strong> Giuseppe </strong>"

 

is there any work around for this?

 

thanks

1 Answer, 1 is accepted

Sort by
1
Petar
Telerik team
answered on 11 Aug 2021, 01:55 PM

Hi Giuseppe,

Here is a StackBlitz example demonstrating how the targeted functionality can be implemented. To achieve this behavior, the cell column property is used. The value passed to the cell prop is the below slot template:

<template v-slot:myTemplate="{props, listeners}">
            <td  :class="props.className" v-html="getNestedValue(props.field, props.dataItem)"> 
            </td>
</template>

The key thing in the above template is the usage of the v-html directive

Let me know if you have questions about the suggested solution. 

Regards,
Petar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Giuseppe
Top achievements
Rank 1
commented on 17 Aug 2021, 08:23 AM

i owe you a beer :) thanks a lot
Petar
Telerik team
commented on 17 Aug 2021, 08:39 AM

You are welcome, Giuseppe. I am happy to hear that the suggested solution works in your scenario :)
Dev
Top achievements
Rank 1
Iron
Iron
commented on 16 Sep 2022, 07:43 AM

Hi Petar,

What about export grid to excel, I also want the same  result. 

How can I do this?

Plamen
Telerik team
commented on 19 Sep 2022, 06:25 AM

In Excel export we can't render the HTML directly. We will need a separate logic to display the exported result as we want. It can be achieved either by customising the cell options as it is described here - https://www.telerik.com/kendo-vue-ui/components/excel-export/cells/ or by workbook customisation as it is described here - https://www.telerik.com/kendo-vue-ui/components/excel-export/customization/.

 

Tags
Grid
Asked by
Giuseppe
Top achievements
Rank 1
Answers by
Petar
Telerik team
Share this question
or