Kendo-ui MVC 弹出式编辑器:如何隐藏字段 [英] Kendo-ui MVC PopUp editor: How to hide fields

查看:18
本文介绍了Kendo-ui MVC 弹出式编辑器:如何隐藏字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Kendo ASP.NET MVC,我想对编辑表单进行一些控制.

I'm using Kendo ASP.NET MVC and I would like to have some control over the edit form.

我想做的事情:

  • 隐藏我的 ID 字段
  • 将我的属性代码和平方英尺更改为常规 TextBoxFor 字段
  • 将购买日期和销售日期更改为 Kendo DatePickerFor 而不是显示的 DateTimePickerFor.

链接到编辑器表单的屏幕截图

推荐答案

当您单击编辑时,Kendo 使用对象的默认 EditorTemplate.如果您不熟悉编辑器模板的工作方式,请查看 这篇文章.

When you click edit, Kendo uses the default EditorTemplate for the object. If you're not familiar how editor templates work, check this article.

您有两种解决方法,一种是创建仅列出您想要的字段的自定义视图编辑器模板.或者(这是更简单和首选的方法),在许多情况下,您可以使用默认的编辑器模板,并使用对象上的元数据控制呈现哪些字段(以及如何呈现).您可以通过使用 [ScaffoldColumn(false)] 属性标记它们来隐藏单个属性.在控制显示的编辑器类型方面,您可以通过使用 [DataType(DataType.Date)][DataType(DataType.Text)] 标记您的属性来实现此目的代码>

You have two ways of solving it, either by creating a custom view editor templates that only lists the fields you want. Or (and this is simpler and preferred method), in many cases you can get away with the default editor template and control which fields are rendered (and how) using metadata on the object. You can hide individual properties by tagging them with [ScaffoldColumn(false)] attribute. In terms of controlling the types of editors that show up, you can accomplish this by tagging your properties with [DataType(DataType.Date)] or [DataType(DataType.Text)]

这篇关于Kendo-ui MVC 弹出式编辑器:如何隐藏字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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