I have an mvc editor template (named ExpenseTypeEdit) defined like this:
@model ExpenseType
@(Html.Kendo().DropDownListFor(et => et.ExpenseTypeId)
.OptionLabel("--Please Select--")
.DataTextField("Description")
.DataValueField("ExpenseTypeId")
.DataSource(datasource => datasource
.Read("GetExpenseTypeList", "Lookup", new { area = "" })
)
.HtmlAttributes(new { width = "98%" })
)
I have a kendo grid that looks something like this:
@(Html.Kendo().Grid<ExpenseViewModel>()
.Name("ExpenseGrid")
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Columns(columns =>
{
columns.Bound(e => e.ExpenseType)
.EditorTemplateName("ExpenseTypeEdit");
columns.Command(command =>
{
command.Custom("SaveExpense").Click("SaveExpense_click").Text("Save");
}
);
})
.DataSource(datasource => datasource.Ajax()
.ServerOperation(false)
.Model(model =>
{
model.Id(i => i.ExpenseId);
model.Field(f => f.ExpenseType)
.DefaultValue(new Solutions.Business.Entities.PrimitiveObjects.ExpenseType { ExpenseTypeId = 0, Description = "" });
})
)
)
The function SaveExpense_click looks like this:
function SaveExpense_click(e) {
var item = this.dataItem($(e.currentTarget).closest("tr"));
/*
Variable 'item' looks like like:
{
ExpenseType: {
ExpenseTypeId: 4,
Description: ""
}
}
*/
//debugger;
};
The ExpenseTypeId is present but not the description. Why is item not picking up the Description from the drop down and what do I need to do to get it passed in?