Hi,
I am creating a property grid control in MVC and so I need to pass a collection of model attributes to the grid. because each model property has different type and so different editor, e.g. the int property may use a dropdown for edit or simple text. here is the basic structure.
public enum PropertyGridEditorTemplate
{
Default,
DateTime,
DropDown,
....
}
public class PropertyMetaDataValue
{
public object CurrentValue { get; set; }
public object DefaultValue { get; set; }
public PropertyGridEditorTemplate Editor { get; set; }
}
public class PropertyMetaData
{
public string GroupName { get; set; }
public string PropertyName { get; set; }
[ReadOnly(true)]
public string DisplayName { get; set; }
public PropertyMetaDataValue Value { get; set; }
}
In the view, I have a grid like this:
@(Html.Kendo().Grid(Model.MetaDatas)
.Name("propertyPanel")
.Columns(columns =>
{
...
columns.Bound(p => p.DisplayName);
columns.Bound(p => p.Value.CurrentValue).EditorTemplateName("PropertyGridEditor");
})
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Model(model => model.Id(p => p.PropertyName))
.Read(read => read.Action("Fee_Read", "Home", new { feeSheetId = Model.FeeSheetID, feeTypeId = Model.FeeID }))
.Group(g => g.Add( grp => grp.GroupName))
)
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Navigatable()
.TableHtmlAttributes(new { @class = "property-grid"})
)
Now the issue is, in custom editor I want to check the "Editor" value and based on that show different control. but there is no way to pass the "Editor" to the custom editor. I tried ViewData which didn't work. also tried Template column but the issue is I can't set custom editor for template.
Any thoughts?
I am creating a property grid control in MVC and so I need to pass a collection of model attributes to the grid. because each model property has different type and so different editor, e.g. the int property may use a dropdown for edit or simple text. here is the basic structure.
public enum PropertyGridEditorTemplate
{
Default,
DateTime,
DropDown,
....
}
public class PropertyMetaDataValue
{
public object CurrentValue { get; set; }
public object DefaultValue { get; set; }
public PropertyGridEditorTemplate Editor { get; set; }
}
public class PropertyMetaData
{
public string GroupName { get; set; }
public string PropertyName { get; set; }
[ReadOnly(true)]
public string DisplayName { get; set; }
public PropertyMetaDataValue Value { get; set; }
}
In the view, I have a grid like this:
@(Html.Kendo().Grid(Model.MetaDatas)
.Name("propertyPanel")
.Columns(columns =>
{
...
columns.Bound(p => p.DisplayName);
columns.Bound(p => p.Value.CurrentValue).EditorTemplateName("PropertyGridEditor");
})
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Model(model => model.Id(p => p.PropertyName))
.Read(read => read.Action("Fee_Read", "Home", new { feeSheetId = Model.FeeSheetID, feeTypeId = Model.FeeID }))
.Group(g => g.Add( grp => grp.GroupName))
)
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Navigatable()
.TableHtmlAttributes(new { @class = "property-grid"})
)
Now the issue is, in custom editor I want to check the "Editor" value and based on that show different control. but there is no way to pass the "Editor" to the custom editor. I tried ViewData which didn't work. also tried Template column but the issue is I can't set custom editor for template.
Any thoughts?