i have a module with additional "dynamic" propertys, stored in a dictionary (loaded from DB, style of Entity-Attribute-Value.
the module like this:
public
class
Contact
{
public
int
ContactID {
get
;
set
; }
public
string
FullName {
get
;
set
; }
//...more fixed properties
#region "handel dynamic property"
public
Dictionary<
int
,
string
> ValuesForDynamicProps = PropsNameToSpcailParameter.Values.ToDictionary(x => x.IdParameter, x =>
""
);
private
void
intDicFromContact(DAL.Contact contact)
{
foreach
(var item
in
contact.ContactsParameters)
{
ValuesForDynamicProps[item.Parameter] = item.GetString;
}
}
static
StudentVM()
{
PropsNameToSpcailParameter = DAL.Contact.SpecialParamertersTypes().ToDictionary(x => x.ID, x =>
new
ModelSpecialParameter(x));
}
public
static
Dictionary<
int
, ModelSpecialParameter> PropsNameToSpcailParameter;
#endregion
}
the View:
@(Html.Kendo().Grid(Contact)
.Name(
"grid"
)
.Columns(columns =>
{
columns.Bound(e => e.FullName).Width(120).Title(
"Name"
);
//...more
foreach
(var item
in
ShutafimOrganizationsWebApp.UI.Models.StudentVM.PropsNameToSpcailParameter)
{
columns.Bound(e => e.ValuesForDynamicProps[item.Key]).Title(item.Value.DisplayName);
}
I receive an exeption ""Bound columns require a field or property access expression."
MY QUESTION: i serarch an elegant and easy way to show in grid an model with posibilty to add and remove "virtual" propertys.
Ps: i asked in stackoverflow: http://stackoverflow.com/questions/30650326.