I am trying to create a grid with 4 columns: Field, Operator, Value and a Delete button
The Field column is selectable from a drop down when editing and this I have done using a Action call.
The second column, Operator has a fixed set of operators like '>', '<', '>='. I was hoping to create this list right inside this grid definition. So I chose the overload: columns.ForeignKey(memberName, SelectList) and I have created a SelectList in the second argument. But it does not work and the Operator column is not showing a drop down:
@(
Html.Kendo().Grid<formFilter>()
.Name("gridFilter")
.ToolBar(toolbar =>
{
toolbar.Create().Text("Add");
toolbar.Save().Text("Save").CancelText("Cancel");
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Columns(columns =>
{
columns.ForeignKey(c => c.filterName, ds => ds.Read(r => r.Action("fieldNames", "View1", new { className = "View1" })), "filterName", "filterName").Title("Field").Width(200);
columns.ForeignKey(c => c.filterEval, new SelectList(
new List<SelectListItem>
{
new SelectListItem { Text = ">", Value = ">"},
new SelectListItem { Text = "<", Value = "<"},
new SelectListItem { Text = ">=", Value = ">="},
}, "Value", "Text"))
.Title("Operator").Width(200);
columns.Bound(c => c.filterValue).Title("Value");
columns.Command(c => c.Destroy()).Width(50);
})
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("ErrorHandlerForFilterTable"))
.Model(model =>
{
model.Id(p => new { p.filterId });
})
.Create("createFilter", "View1")
.Read(read => read.Action("getFiltersTable", "View1", new { url = @Context.Request.Path }))
.Update("updateFilter", "View1")
.Destroy(del => del.Action("deleteFilter", "View1"))
)
)