How to force DataColumnElement display HTML?

Posted by Community Admin on 04-Aug-2018 06:46

How to force DataColumnElement display HTML?

All Replies

Posted by Community Admin on 31-May-2011 00:00

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);

I'd like to use a similar configuration to display description.
DataColumnElement descriptionColumn = new DataColumnElement(gridMode.ColumnsConfig)
    Name = "Description",
    HeaderText = Res.Get<ProductsResources>().Description,
    ClientTemplate = @"Description"
;
gridMode.ColumnsConfig.Add(descriptionColumn);

The description have to be displayed with HTML formatting:
This is the first description of product.

Currently, it shows the description with HTML tags in the plain text mode:
This is the first <b>description</b> of product.

Is there a way to accomplish this?

Best regards,
Anton

Posted by Community Admin on 31-May-2011 00:00

Hello Anton,

You can try using

  • HeaderCssClass- Determines the css class of the header for this data item.
  • ItemCssClass- Determines the css class for the item.

Here is a list with all properties of the ColumnElement that you can set
All the best,
Ivan Dimitrov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 19-Dec-2011 00:00

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?

Posted by Community Admin on 20-Dec-2011 00:00

Hi Victor,

This is the purpose of ClientTemplate . HeaderCssClass and ItemCssClass are supposed to serve only css.

Greetings,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 20-Dec-2011 00:00

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?


This thread is closed