Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo-ui MVC PopUp editor: How to hide fields

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

like image 884
Mithrilhall Avatar asked Nov 14 '12 21:11

Mithrilhall


1 Answers

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

like image 134
Andrew Stakhov Avatar answered Sep 26 '22 00:09

Andrew Stakhov