How to force DataColumnElement display HTML?
Hi guys,
In the Products sample there is a declaration of column that displays the title of a product:
DataColumnElement titleColumn = new DataColumnElement(gridMode.ColumnsConfig)
Name = "Title",
HeaderText = Res.Get<
Labels
>().Title,
HeaderCssClass = "sfTitleCol",
ItemCssClass = "sfTitleCol",
ClientTemplate = @"<
a
sys:href
=
'javascript:void(0);'
sys:class
=
""
'sf_binderCommand_edit sfItemTitle sf' + UIStatus.toLowerCase()"">
<
strong
>Title</
strong
>
<
span
class
=
'sfStatusLocation'
>Status</
span
></
a
>"
;
gridMode.ColumnsConfig.Add(titleColumn);
DataColumnElement descriptionColumn =
new
DataColumnElement(gridMode.ColumnsConfig)
Name =
"Description"
,
HeaderText = Res.Get<ProductsResources>().Description,
ClientTemplate = @
"Description"
;
gridMode.ColumnsConfig.Add(descriptionColumn);
This is the first description of product.
This is the first <
b
>description</
b
> of product.
Hello Anton,
You can try using
That's fine for style, but what if the field actually holds HTML (such as links). Is there anyway to have that HTML not be escaped?
Hi Victor,
This is the purpose of ClientTemplate
. HeaderCssClass and ItemCssClass are supposed to serve only css.
Greetings,
Ivan Dimitrov
the Telerik team
Sorry my question was unclear. I have a field in my database called myHTML, this field can contain various links, bold, italics, etc. and is stored in the database as HTML in a string field.
In my client template I have the following string "<div>myHTML</div>".
When the grid is bound on the client, the field appears as plain text, not HTML. The HTML gets "escaped" so instead of seeing a link, I literally see the "a" tag.
If there a way to avoid this?