我对 GridMvc 库有疑问。我想添加包含带
分隔符的字符串连接表的列,这是我的代码:
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);
但结果我得到:
Easy<br/>Hard
您知道为什么它不起作用吗?
最佳答案
您看到的是编码的 <br/>
, 因此您需要删除对 HtmlEncode()
的调用方法。此外,来自 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);
关于c# - GridMvc 错误地在列中显示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18773727/