I had a grid that used an "editor template":
ie.
c.ForeignKey(r => r.repeatedTestTypeID, (IEnumerable<Model.Models.RepeatedTestType>)ViewData["tt"],
"repeatedTestTypeID", "repeatedTestTypeDesc").EditorTemplateName("TestTypeTemplate").Title("Test Type").Width("180px");
This worked fine, showing the proper textual representation of a fk id value, however in the popup editor shown when you click add new record, an integer text box was shown rather than the desired drop down list of values.
FYI, the template editor code is at the bottom of this note.
In order to get it to work, I had to add an attribute to the POCO class object:
[UIHint("TestTypeTemplate")]
public int repeatedTestTypeID { get; set; }
Editor Template code below, it is placed in the Views/Shared folder:
@using Kendo.Mvc.UI
@{
Layout = null;
}
@(Html.Kendo().DropDownList()
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetFunctionalClasses", "TreadMillWalkTests");
});
})
.DataTextField("functionalClassDesc")
.DataValueField("functionalClassID")
//.DataValueField("ANAPatternDesc")
//.SelectedIndex(0)
.Name("functionalClassID")
.OptionLabel("- Please select -")
.HtmlAttributes(new { data_value_primitive = true})
)
No comments:
Post a Comment