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
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
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
Our thoughts here at Progress are with those affected by the outbreak.
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
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
Doncho,
that explains it. Thanks for the clarification.
Best,
Michael