This is a migrated thread and some comments may be shown as answers.

Grid cells are showing HTML tags with version 2020.2.617.45

5 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Iron
Michael asked on 02 Jul 2020, 06:28 AM

Hi,

we are currently trying to migrate our Web application from Telerik controls version 2014.2.724.40 to version 2020.2.617.45. In our code we create GridBoundColumns using

 column = new GridBoundColumn{DataFormatString = "<nobr>{0}</nobr>"};

Now when running the application with version 2020.2.617.45 the <nobr> tags show up in the grid cells, whereas they do not when using version 2014.2.724.40. In the attached picture the above grid is with version 2014.2.724.40 and the lower with version 2020.2.617.45.

What am I missing?

Thanks,

Michael

5 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
Iron
answered on 03 Jul 2020, 12:39 PM

Update:

I started playing with the Telerik samples and there the above described effect does not occur.

Then I stripped our code down to fill only those properties of the GridBoundColumn that appear in the Telerik samples. After some trying I found out that we set GridBoundColumn.HtmlEncode to true in our code and if I comment out that statement the cell values display fine.

I tried to set GridBoundColumn.HtmlEncode to true also in the Telerik samples, but it did not have the same (negative) effect as it does in our code

0
Accepted
Doncho
Telerik team
answered on 06 Jul 2020, 02:48 PM

Hi Michael,

You have found the right solution to the issue!

The HtmlEncode property is exposed for controlling if the HTML tags should be applied as HTML elements or to be literally displayed. By default, its value is set to false.

Setting the HtmlEncode to 'true' will result in tags displayed as plain text in the Grid cell, like ("<b>Name 1</b>"). If set to false the same cell content would look like "Name 1".
Please clarify which Telerik sample has a different behavior than the described one, so that we can take a closer look at it and investigate it.

As a side note: The <nobr> HTML element is claimed to be a deprecated one. You may consider using the CSS white-space Property instead, see <nobr>: The Non-Breaking Text element (obsolete).

Kind regards,
Doncho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Michael
Top achievements
Rank 1
Iron
answered on 09 Jul 2020, 10:30 AM

Thanks Doncho,

with your explanation I do not think there is an issue with your code or sample. The strange thing is just that our code (with HtmlEncode set to true) behaves differently depending on the Telerik version we are using:

2014.2.724.40: does not show the <nobr> tags (which is kind of unexpected with your explanations)

2020.2.617.45: does show them (which seems to be correct)

Anyway, I think we will set the flag to false or use the CSS white-space property instead of the <nobr>

Best,

Michael

0
Doncho
Telerik team
answered on 10 Jul 2020, 03:13 PM

Hi Michael,

The difference in the behavior is related to the simultaneous use of HtmlEncode and DataFormatString properties.

In the old 2014 version, the value of the field is encoded before applying the string format, therefore, tags introduced in the DateFormatString are not encoded, even if HtmlEncode='true'

In newer versions, encoding applies after formatting, and you can decide if the already formatted value to be encoded or not.

Kind regards,
Doncho
Progress Telerik

0
Michael
Top achievements
Rank 1
Iron
answered on 13 Jul 2020, 10:10 AM

Doncho,

that explains it. Thanks for the clarification.

Best,

Michael

Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Iron
Answers by
Michael
Top achievements
Rank 1
Iron
Doncho
Telerik team
Share this question
or