i have a model with dynamic "propertys" (in DB level, something similar to Entity-Attribute-Value system).
The properties are in a field of Dictionary<int, string>
, and would like to show them into columns.
Model:
the model have a static array (initalized in static counstractor) of "property" names & keys:
public static ModelSpecialParameter[] SpecialFields;
and a Dictionary (initalized in model create, and all posible keys added) with their values.
public Dictionary<int, string> ValuesForDynamicProps;
The View:
@(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =>
{
//other columns for realy propertry
//columns.Bound(e => ...
//columns.Bound(e => ...
foreach (var item in SpecialFields) // SpecialFields is a static collection. represent the name an id of the dynamic property's.
{
columns.Bound("ValuesForDynamicProps[" + item.IdProperty + "]").Width(140).Title(item.DisplayName);
}
}
I get an error:
{"Bound columns require a field or property access expression."}
i tryed also:
columns.Bound(e => e.ValuesForDynamicProps[item.IdProperty]).Width(140).Title(item.DisplayName);
the same error.
Even if what I want is not possible I am looking for an idea how to get the desired result: Flexibility in adding and removing properties.