The objects that are enumerated in my Kendo MVC Grid are of type dynamic:
I am using InLine editing. I am able to specify the editor for each of my fields as described here:
http://www.telerik.com/forums/inline-editing-mode-and-dynamic-object
http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/editor-templates
I won't reiterate the approach that is described above, but in summary it involves adding a UIHint attribute to fields in the model, and then using EditorTemplateName to identify an editor template for the field (and that editor template refers to the field via the Name() method). This works.
The problem that I have is that many of my fields need to appear in non-editable columns. My hope was that I could get the grid to render those fields as is (no editor) by:
a. Omit the UIHint attribute from model properties that would not be editable
b. Not specify an EditorTemplateName for non-editable bound columns
c. Set Editable(false) when defining the model (as below):
However, when I do this the grid fails to load and I see an exception in Fiddler:
I have many fields and most of them wil be non-editable, so I would rather not, for example, create editor templates for each of them that contain disabled controls.
What is the best way to configure all my non-editable columns in an InLine grid that is bound to dynamic objects?
thanks,
Derek
@(Html.Kendo().Grid<
dynamic
>()
...
I am using InLine editing. I am able to specify the editor for each of my fields as described here:
http://www.telerik.com/forums/inline-editing-mode-and-dynamic-object
http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/editor-templates
I won't reiterate the approach that is described above, but in summary it involves adding a UIHint attribute to fields in the model, and then using EditorTemplateName to identify an editor template for the field (and that editor template refers to the field via the Name() method). This works.
The problem that I have is that many of my fields need to appear in non-editable columns. My hope was that I could get the grid to render those fields as is (no editor) by:
a. Omit the UIHint attribute from model properties that would not be editable
b. Not specify an EditorTemplateName for non-editable bound columns
c. Set Editable(false) when defining the model (as below):
.DataSource(d =>
{
d.Ajax()
.Model(m =>
{
m.Id("Id");
m.Field("Name", typeof(string)).Editable(false);
However, when I do this the grid fails to load and I see an exception in Fiddler:
[RuntimeBinderException: 'object' does not contain a definition for 'Name']
CallSite.Target(Closure , CallSite , Object ) +152
System.Dynamic.UpdateDelegates.UpdateAndExecute1(CallSite site, T0 arg0) +662
lambda_method(Closure , Object ) +133
Kendo.Mvc.UI.Html.GridDataCellBuilder`2.AppendCellContent(IHtmlNode td, Object dataItem) +131
Kendo.Mvc.UI.Html.GridDataCellBuilderBase.CreateCell(Object dataItem) +230
I have many fields and most of them wil be non-editable, so I would rather not, for example, create editor templates for each of them that contain disabled controls.
What is the best way to configure all my non-editable columns in an InLine grid that is bound to dynamic objects?
thanks,
Derek