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

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

问题描述

我正在使用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 PopUp编辑器:如何隐藏字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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