This is a migrated thread and some comments may be shown as answers.

Non-editable column in InLine grid with dynamic items

2 Answers 245 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 22 Jan 2015, 04:05 PM
The objects that are enumerated in my Kendo MVC Grid are of type dynamic:

@(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

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 26 Jan 2015, 09:53 AM
Hi Derek,

Indeed, you should be able to disable the editing for given field by setting its Editable option to false. However, this, as seems, does not work in the scenario in question as we were able to replicate the error you have described. Fortunately, we manage to address it and the fix will be included in the next internal build. Meanwhile, I have updated your telerik points.

Regards,
Rosen
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Derek
Top achievements
Rank 1
answered on 06 Feb 2015, 04:59 PM
Hi Rosen,

Thank you very much.  I have verified that the problem I described is fixed in internal build 2014.3.1328.545.  I appreciate the prompt and successful resolution.

Derek
Tags
Grid
Asked by
Derek
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Derek
Top achievements
Rank 1
Share this question
or