【问题标题】:Kendo Grid (ASP.NET MVC) Error with Unicode Character带有 Unicode 字符的 Kendo Grid (ASP.NET MVC) 错误
【发布时间】:2018-02-12 19:47:59
【问题描述】:

我遇到了一个充满数据表的剑道网格问题。它工作得很好,直到我在传递给网格的 DataTable 的列名中添加了一些 unicode 字符。抛出了一个无效的模板错误,我很确定这是因为 unicode 字符。

Error: Invalid template:
    '<tr data-uid="#=data.uid#" role='row'>
       <td  role='gridcell'>#:data.CID????==null?'':data.CID????#</td>
       <td role='gridcell'>#:data.INFO==null?'':data.INFO#</td>
       <td  role='gridcell'>#:data.HISTORY==null?'':data.HISTORY#</td>
     </tr>'
Generated code:
    'var $kendoOutput, $kendoHtmlEncode = kendo.htmlEncode;with(data)
    {$kendoOutput=
        '<tr data-uid="'+(data.uid)+'" role=\'row\'>
           <td  role=\'gridcell\'>'+$kendoHtmlEncode(data.CID????==null?'':data.CID????)+'</td>
           <td  role=\'gridcell\'>'+$kendoHtmlEncode(data.INFO==null?'':data.INFO)+'</td>
           <td  role=\'gridcell\'>'+$kendoHtmlEncode(data.HISTORY==null?'':data.HISTORY)+'</td>
         </tr>'
    ;}return $kendoOutput;

这个问题有解决办法吗?

感谢您的帮助!

【问题讨论】:

    标签: asp.net-mvc kendo-grid


    【解决方案1】:

    您可以将编码值设为假。 如果设置为 true,则列值将在显示之前进行 HTML 编码

     columns: [
        { field: "name", encoded: false }
      ]
    

    例子:

    $("#grid").kendoGrid({
      columns: [
        { field: "sample", encoded: false }
      ],
      dataSource: [ { sample: "<strong>Sample String</strong>" } ]
    });
    

    如果问题与.net core 中的剑道有关,请检查this

    【讨论】:

    • 我尝试了调整后的GridColumnSettingsencoded=false 设置运行网格的行并且没有修复错误。我将使用 JavaScript 更改列名,因为这似乎是目前最简单的解决方法。无论如何,感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 2014-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-23
    • 2014-12-05
    • 1970-01-01
    • 2013-08-25
    相关资源
    最近更新 更多