Kendo UI Grid - 客户端模板:转义 # 符号 [英] Kendo UI Grid - Client Template: Escaping # sign

查看:40
本文介绍了Kendo UI Grid - 客户端模板:转义 # 符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Kendo UI 的网格以及 Twitter Bootstrap.

I'm working with Kendo UI's grid, along with Twitter Bootstrap.

Twitter Bootstrap 有一个内置的弹出窗口/模式,可以通过以下方式调用:

Twitter Bootstrap has a built in pop-up/modal that can be called with:

<a href="#" class="text-yellow" data-toggle="modal" data-target="#login">Login</a>

在我的 Kendo UI 网格中,我有一个自定义列模板:

In my Kendo UI grid, I have a custom column template:

   columns.Template(e => { }).ClientTemplate("<span data-toggle='modal' data-target='#login' title='Flag Animals as Dead or Deceased' style='cursor:pointer;' class='glyphicon glyphicon-flag flag-dead text-red'></span>").Width(50);

这是我遇到问题的地方,如果您注意到了,您需要使用 # 符号指定模态窗口的 Id.即 data-target='#login'

This is where I am having my issue, if you noticed, you need to specify the Id of the modal window with a # sign. ie data-target='#login'

每当我的网格模板中出现 # 符号时,网格就会中断.我怎样才能逃离这个标志?

Whenever the # sign is in my grid template, the grid breaks. How can I escape this sign?

推荐答案

您可以像这样使用 \ 字符转义 # data-target='\#login'

You can escape # using \ character like this data-target='\#login'

更新:来自 Telerik 文档 kendo 模板

UPDATE: From telerik documentation kendo templates

如果您的模板包含文字 # 字符,它不是绑定表达式的一部分,也不是脚本代码标记,那么您必须转义该字符,否则会导致模板编译错误.例如,如果在超链接 URL 或 CSS 颜色值中使用 #,就会发生这种情况.Javascript 字符串中的文字 # 用 \\# 转义,而外部 HTML 脚本模板中的文字 # 用 \# 转义.

If your template includes a literal # character, which is not part of a binding expression and is not a script code marker, then you must escape that character or it will cause a template compilation error. For example, this can happen if a # is used inside a hyperlink URL or a CSS color value. Literal # in Javascript strings are escaped with \\#, while literal # in external HTML script templates are escaped with \#.

这篇关于Kendo UI Grid - 客户端模板:转义 # 符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆