I have a Kendo UI ASP.NET MVC grid with CRUD operations that is being submitted as part of a form. In the following snippet, I am trying to display a column with an inline editable combobox (bound to user names and IDs) that displays a user's name but has a value of the user's ID.
Submits form properly, but displays the user IDs rather than names:
ComboBoxInForm EditorTemplate:
If I remove the ClientTemplate that provides the form input tag, the user's name is what is displayed rather than the value of the user's ID which is what I want. However, I need to submit it in batch as a part of a form, so I cannot remove the form input tag.
Fails to submit the form (no input tag), but displays the user names rather than IDs correctly:
Submits form properly, but displays the user IDs rather than names:
columns.ForeignKey(p => p.UserId, (System.Collections.IEnumerable)ViewBag.Users,
"SystemUserId"
,
"Name"
).Title(
"User"
).EditorTemplateName(
"ComboBoxInForm"
).Visible(
true
).ClientTemplate(
"#= UserId #"
+
"<input type='hidden' name='Users[#= index(data) #].UserId' value='#= UserId #' />"
);
ComboBoxInForm EditorTemplate:
@model
object
@(
Html.Kendo().ComboBoxFor(m => m)
.BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName(
""
) +
"_Data"
])
)
If I remove the ClientTemplate that provides the form input tag, the user's name is what is displayed rather than the value of the user's ID which is what I want. However, I need to submit it in batch as a part of a form, so I cannot remove the form input tag.
Fails to submit the form (no input tag), but displays the user names rather than IDs correctly:
columns.ForeignKey(p => p.UserId, (System.Collections.IEnumerable)ViewBag.Users,
"SystemUserId"
,
"Name"
).Title(
"User"
).EditorTemplateName(
"ComboBoxInForm"
).Visible(
true
);
What solution can I use to combine these two requirements so that the grid column displays names (but with values of IDs) and also provides the form input tag?
Thanks.
Note: Cross-posted from here.