Greetings,
I've created a grid, that displays details of an root-object. The Problem ist, that the detail-object is generated dynamically, so a direct binding to columns is not possible because we don't know what members this object has.
The "anonymous" columns in the detail-object should be filterable, but this doesn't work. Weird, because grouping is working. (The DatasourceRequest-Object in the controller seems to be correct - it has filter-definitions and group-definitions).
How can i get filtering working in my anonymous object?
This is the controller (the object "DynParts" ist the ICollection of the same dynamically created objects):
This is the view:
I've created a grid, that displays details of an root-object. The Problem ist, that the detail-object is generated dynamically, so a direct binding to columns is not possible because we don't know what members this object has.
The "anonymous" columns in the detail-object should be filterable, but this doesn't work. Weird, because grouping is working. (The DatasourceRequest-Object in the controller seems to be correct - it has filter-definitions and group-definitions).
How can i get filtering working in my anonymous object?
This is the controller (the object "DynParts" ist the ICollection of the same dynamically created objects):
public
ActionResult HierarchyBinding_Types([DataSourceRequest] DataSourceRequest request)
{
IQueryable<pxCore.Type> _types =_db.Types.OrderBy(t=>t.Kurzzeichen);
DataSourceResult _dsr = _types.ToDataSourceResult(request, _type =>
new
Typeview(_type, _db));
return
Json(_dsr);
}
public
ActionResult HierarchyBinding_DynParts(Guid typeid, [DataSourceRequest] DataSourceRequest request)
{
Typeview typeview=
new
Typeview(_db.Types.Where(w=>w.Id==typeid).FirstOrDefault(), _db);
DataSourceResult _dsr = typeview.DynParts.ToDataSourceResult(request);
return
Json(_dsr);
}
This is the view:
@(Html.Kendo().Grid<
pxCore.Type
>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.Kurzzeichen).Width(110);
columns.Bound(e => e.Bezeichnung).Width(510);
})
.Sortable()
.Scrollable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.ClientDetailTemplateId("template")
.HtmlAttributes(new { style = "height:700px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("HierarchyBinding_Types", "Types"))
)
.Events(events => events.DataBound("dataBound"))
)
<
script
id
=
"template"
type
=
"text/kendo-tmpl"
>
@(Html.Kendo().Grid<
object
>()
.Name("grid_#=Id#")
.Resizable(r=>r.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Read(read => read.Action("HierarchyBinding_DynParts", "Types", new { typeID = "#=Id#" }))
)
.Pageable()
.Groupable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.Sortable()
.Reorderable(r=>r.Columns(true))
.ToClientTemplate()
)
</
script
>