Kendo 模板中的 Switch 语句 [英] Switch Statement in Kendo Template

查看:21
本文介绍了Kendo 模板中的 Switch 语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Kendo 模板,并且我能够创建文档中所述的条件语句(IF 语句).这是我的代码.

Im using Kendo Template and I was able to create a conditional statement (IF statement) as stated on the documentaion. Here's my code.

#if ((item.ControlType) == "tbx"){#
   @(Html.Kendo().AutoComplete()
   .Name("#=ctrlid#")
   .ToClientTemplate())
#}#

这很好用.

但我想要的是切换案例声明.我试过这个,但它不起作用.上面写着模板无效".

But what I'd like to have is a Switch Case Statement. I've tried this but it doesn't work. It says "Invalid Template".

# switch (item.ControlType) {#
  # case "tbx": #
     @(Html.Kendo().AutoComplete()
       .Name("#=ctrlid#")
       .ToClientTemplate())
  # break; #
  # }#

我错过了什么吗?或者 Kendo 模板无法解释 Switch Case 语句?(关于后者,我不这么认为......我肯定错过了一些东西)

Am I missing something? Or is it just impossible for Kendo Template to interpret Switch Case Statements? (about the latter, I dont think so..I'm definitely missing something)

有人可以帮我吗?谢谢!^^

Can anyone help me please? Thanks!^^

推荐答案

我检查了你的情况,我找到了错误的原因.基本上,为了保持 JavaScript 有效,您将只需要在 switch 语句和第一个 case 语句周围使用一对 # 符号.

I check your case and I found the reason for the error. Basically to keep the JavaScript valid you will have to use only one pair of # symbols surounding the switch statement and the first case statement.

例如

代替:

# switch (item.ControlType) {#
# case "tbx": #

使用:

# switch (item.ControlType) {
  case "tbx": #

为了演示它,这里有一个 jsbin.如果将 switch 与 MVC 包装器生成的一些小部件结合起来,基本上应该不会有问题.如果有,请告诉我.

To demonstrate it , here is a jsbin. Basically there should not be problems if you combine the switch with some widget generated by the MVC wrappers. If there is, let me know.

这篇关于Kendo 模板中的 Switch 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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