asp.net mvc - Telerik mvc grid, columns.bound to dictionary value. or "dynamic property in model" -
i have model dynamic "propertys" (in db level, similar entity-attribute-value system). properties in field of dictionary<int, string>
, , show them columns.
model:
the model have static array (initalized in static counstractor) of "property" names & keys:
public static modelspecialparameter[] specialfields;
and dictionary (initalized in model create, , posible keys added) values.
public dictionary<int, string> valuesfordynamicprops;
the view:
@(html.kendo().grid(model) .name("grid") .columns(columns => { //other columns realy propertry //columns.bound(e => ... //columns.bound(e => ... foreach (var item in specialfields) // specialfields static collection. represent name id of dynamic property's. { columns.bound("valuesfordynamicprops[" + item.idproperty + "]").width(140).title(item.displayname); } }
i error:
{"bound columns require 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 want not possible looking idea how desired result: flexibility in adding , removing properties.
there isn't easy way directly fluent api. have it's ajax call method return json structured data in one.
or try other way, it's same idea trying. maybe can you: https://mycodepad.wordpress.com/2014/12/01/asp-net-mvc-5-with-razor-kendo-ui-dynamic-grid-creation-columns-ordering-grouping-and-paging/
Comments
Post a Comment