This question is locked. New answers and comments are not allowed.
I have the MVC grid displaying a lookup field similar to this:
<%= Html.Telerik().Grid(Model)
.TableHtmlAttributes(new { style = "table-layout:fixed" })
.Name("MachinesGrid")
.DataKeys(keys => keys.Add(c => c.Id))
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Text).ImageHtmlAttributes(new { style = "margin-left:0" }))
.DataBinding(dataBinding => dataBinding.Server()
.Select("Index", "Machine")
.Insert("Insert", "Machine")
.Update("Save", "Machine")
.Delete("Delete", "Machine"))
.Columns(columns =>
{
columns.Bound(m => m.Name).Width(150);
columns.Bound(m => m.LocationId);
})
.Editable(editing => editing.Mode(GridEditMode.PopUp))
.Pageable()
.Sortable()
.Filterable()
%>
I have a DisplayTemplate called Location.ascx that looks like this:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<int?>" %>
<% var x =
((IEnumerable<SelectListItem>) ViewData[ViewData.ModelMetadata.PropertyName])
.Where(l => l.Value == Model.ToString())
.Select(l => l)
.SingleOrDefault();
%>
<%: x == null ? "" : x.Text %>
The result is that the grid displays the name of the location foreign key perfectly. But when filtering, the value edit control is only allowing me to type numbers. If I type in the id value for a given location, it will filter, but that is more than a little complicated for users.
What do I need to do in order to type the names that are displayed in the location column drive the filtering in the grid?
Thanks.
<%= Html.Telerik().Grid(Model)
.TableHtmlAttributes(new { style = "table-layout:fixed" })
.Name("MachinesGrid")
.DataKeys(keys => keys.Add(c => c.Id))
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Text).ImageHtmlAttributes(new { style = "margin-left:0" }))
.DataBinding(dataBinding => dataBinding.Server()
.Select("Index", "Machine")
.Insert("Insert", "Machine")
.Update("Save", "Machine")
.Delete("Delete", "Machine"))
.Columns(columns =>
{
columns.Bound(m => m.Name).Width(150);
columns.Bound(m => m.LocationId);
})
.Editable(editing => editing.Mode(GridEditMode.PopUp))
.Pageable()
.Sortable()
.Filterable()
%>
I have a DisplayTemplate called Location.ascx that looks like this:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<int?>" %>
<% var x =
((IEnumerable<SelectListItem>) ViewData[ViewData.ModelMetadata.PropertyName])
.Where(l => l.Value == Model.ToString())
.Select(l => l)
.SingleOrDefault();
%>
<%: x == null ? "" : x.Text %>
The result is that the grid displays the name of the location foreign key perfectly. But when filtering, the value edit control is only allowing me to type numbers. If I type in the id value for a given location, it will filter, but that is more than a little complicated for users.
What do I need to do in order to type the names that are displayed in the location column drive the filtering in the grid?
Thanks.