Inline editing mode and dynamic object

8 posts, 0 answers
  1. siham
    siham avatar
    1 posts
    Member since:
    Jan 2014

    Posted 16 Jan 2014 Link to this post


    I've created a grid with a dynamic object and I'd like to use the GridEditMode.InLine to update and add data. The popUp mode is working but with the InCell and
    the inline I'm getting the following error:

    Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.

    Am I missing something?

    I tried to use a custom template but I am still getting the same error.
        .DataSource(dataSource => dataSource
            .Model(cfg =>
            foreach (var property in Model.PropertyDescriptors)
                    cfg.Field(property.Name, property.DataType);
            .Read(cfg => cfg.Type(HttpVerbs.Post)
            .Action("ReadDataForDefinition", "ManualDataEntry",
                    new { id = Model.LDefinitionId }))
            .Update(u => u.Type(HttpVerbs.Post).Action("UpdateDataForDefinition", "ManualDataEntry",
                    new { id = Model.LDefinitionId }))
            .Create(u => u.Type(HttpVerbs.Post).Action("Create", "ManualDataEntry",
                    new { id = Model.LDefinitionId }))
          .Resizable(resizing => resizing.Columns(true))
          Columns(columns =>
            foreach (var property in Model.PropertyDescriptors.Where(desc => desc.DisplayOrder.HasValue))
                 var binding = columns.Bound(property.DataType, property.Name);
              if (property.DataType == typeof(DateTime) || property.DataType == typeof(DateTime?))
               binding.Column.Title = property.Label;
          columns.Command(command =>
      .ToolBar(toolbar => { toolbar.Create(); })
      .Pageable(paging =>
      .Editable(edit => edit.Mode(GridEditMode.InLine))
  2. Vladimir Iliev
    Vladimir Iliev avatar
    2206 posts

    Posted 17 Jan 2014 Link to this post

    Hi Siham,

    Basically the error is thrown as internally the Grid builds the default editor templates by calling the "EditorForModel" which doesn't support dynamic type. In order to support different edit modes you should create custom editor template for the model. For more information about setting custom editor templates you can check the following help topic:

    Vladimir Iliev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Louis
    Louis  avatar
    14 posts
    Member since:
    Mar 2011

    Posted 03 Apr 2014 in reply to Vladimir Iliev Link to this post

    I am trying to do something similar, so when I looked into creating the new Editor Templates, it appears you have to set the UIHint attribute on the model. If the model is not created at design time, which is what siham appears to be doing in his example, how to do you tie an Editor Template to a dynamic property?
  4. Vladimir Iliev
    Vladimir Iliev avatar
    2206 posts

    Posted 07 Apr 2014 Link to this post

    Hi Louis,

    You can specify the editor template using the "TemplateName" method:

    .Editable(e => e.Mode(GridEditMode.PopUp).TemplateName("customTemplate"))

    Vladimir Iliev

    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.

  5. gregtayl
    gregtayl avatar
    8 posts
    Member since:
    Jan 2012

    Posted 13 Sep 2016 in reply to Vladimir Iliev Link to this post

    I realize this is an old post, however the 'Model' that gets provided to editor template is null so you end up losing context as to which property you are editing.


    @model decimal
       // Model == null, so the following line returns an empty string for propertName
       var propertyName = ModelMetadata.FromLambdaExpression(o => o, Html.ViewData).PropertyName;
    <input data-role="numerictextbox" data-bind="value:@propertyName"/>

    @(Html.Kendo().Grid(new dynamic[] {})
            .Editable(c => c.Mode(GridEditMode.InCell))
            .Columns(columns =>
                columns.Bound(typeof(decimal), "UnitPrice").EditorTemplateName("MyEditor");

  6. Vladimir Iliev
    Vladimir Iliev avatar
    2206 posts

    Posted 14 Sep 2016 Link to this post

    Hi Greg,

    This behavior is expected as the editor template is executed only once on the server side with empty instance of the Grid model type. Later on the client side the currently edited model is bound to the template HTML output using MVVM.

    Vladimir Iliev
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. Christian
    Christian avatar
    4 posts
    Member since:
    Jun 2014

    Posted 02 Jul 2019 Link to this post

    Why do I get the same error when only adding a delete button?
    Can I avoid calling the editor template, since I don't need it in this case.
    ....Columns(columns =>
        foreach (var prop in properties)
        columns.Command(command => command.Destroy());

  8. Tsvetomir
    Tsvetomir avatar
    757 posts

    Posted 04 Jul 2019 Link to this post

    Hi Christian,

    Generally, adding a simple Delete button in the command column of the grid should not be affecting the overall behavior at all. I have tested out a similar case and it appears that the error is not encountered. It is mandatory for the Destroy functionality to have set the data source as follows:

        .Destroy("Action", "Controller")
        .Update("Action", "Controller"))

    And the columns declaration is set as follows:

    .Columns(columns => {
        foreach(var item in properties)
        columns.Command(cmd => cmd.Destroy());

    I suspect that the issue might stem from something else. Is it possible for you to isolate the faulty behavior in a sample project and send it back to me? This way I would have the opportunity to investigate the case and get back to you with accurate suggestions.

    Looking forward to your reply.

    Kind regards,
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top