GridMvc wrong shows texts in column

900 Views Asked by At

I have a problem with GridMvc library. I want to add column which contains joined table of string with
delimiter, here is my code:

columns.Add()
       .RenderValueAs(
           row => string.Join(
               HttpContext.Current.Server.HtmlEncode("<br/>"),
               row.QuestionDifficultyToPosition.Select(
                   r => r.Difficulty.DifficultyName).ToArray()))
       .Titled("Difficulties")
       .Filterable(true)
       .Sortable(true);

but in the result i get:

Easy&lt;br/&gt;Hard

Do you have any ideas why it doesn't work?

1

There are 1 best solutions below

0
On

You're seeing the encoded <br/>, so you need to remove your call to the HtmlEncode() method. Also, from the docs...

you need to disable default encoding and satinizing cell values, using Encoded and Sanitized method.

columns.Add()
       .Encoded(false)
       .Sanitized(false)
       .RenderValueAs(
           row => string.Join(
               "<br/>",
               row.QuestionDifficultyToPosition.Select(
                   r => r.Difficulty.DifficultyName).ToArray()))
       .Titled("Difficulties")
       .Filterable(true)
       .Sortable(true);