Kendo-ui MVC PopUp editor: How to hide fields

喜欢而已 提交于 2019-12-30 06:36:06

问题


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

Things I would like to do:

  • Hide my ID field
  • Change my Property Code and Square Feet to regular TextBoxFor fields
  • Change Date of Purchase and Date of Sale to Kendo DatePickerFor instead of the DateTimePickerFor that is showing.

Link to screenshot of editor form


回答1:


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

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)]



来源:https://stackoverflow.com/questions/13387316/kendo-ui-mvc-popup-editor-how-to-hide-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!