Hi,
I am working on a grid having inline edit functionality. I am trying to create a dropdown which display a list of persons, however, I want to save the email id of the person in our backend SQL DB.
I am trying to implement this with editor template approach -
I have tried the below code -
Grid:
columns.Bound(mm => mm.Person).Title("Assigned To").EditorTemplateName("PersonList").HeaderHtmlAttributes(new { style = "white-space: normal" });
PersonList.chstml
@(Html.Kendo()
.DropDownList()
.Filter("contains")
.Name("Person")
.DataTextField("Name")
.DataValueField("Email")
.DataSource(dataSource =>
{
dataSource.Read(read => read.Action("GetPeopleByArea", "Common").Data("getPeopleByArea"))
.ServerFiltering(true);
})
//.HtmlAttributes(new { required = "required", data_required_msg = "Select Person Name", style = "width: 100px" })
.ValuePrimitive(true)
.AutoWidth(true)
.OptionLabel("-- Please Select --")
)
function getPeopleByArea() {
var grid = $("#Grid").data("kendoGrid");
var dataItem = grid.dataItem("tr.k-grid-edit-row");
return {
Area: dataItem.Area
};
}
When I edit the grid the dropdown work list works fine and it displays the filtered list of people as expected. However, Instead of the email id the record is getting updated with Null or blanks in the backend table.
However, this approach works fine if I do not use getPeopleByArea function to filter the area based on certain conditions and use a different controller function to get the whole list.
Also, if I am using .DataTextField("Name") and .DataValueField("ID"), ID is getting stored and same is getting displayed on the grid instead of the Name.
What am I doing wrong here ? Can anyone please suggest.
Please let me know if you have any questions.
Thanks
Saurabh