Model's Id value is not available in EditorTemplate

2 posts, 0 answers
  1. Chencharao
    Chencharao avatar
    1 posts
    Member since:
    Apr 2015

    Posted 09 Dec 2015 Link to this post

    I am working on Kendo Grid with MVC.Net. I am using CRUD operations with editor template. I am unable to get the model id value in editor template to figure out if it is a new record or existing record.

     Here is my grid configuration which in cshtml file

                              .Columns(columns =>
                                  columns.Bound(col => col.Id);
                                  columns.Bound(col => col.Name);                            
                                  columns.Command(command => { command.Edit(); command.Destroy(); });
                              .ToolBar(toolbar => toolbar.Create().Text("Add New Record"))
                              .Editable(editable => editable                                                       
                              .DataSource(dataSource =>
                                            .Model(m =>
                                                m.Id(a => a.Id);
                                                m.Field(a => a.Name)                                                                
                                            .Read(read => read.Action("TestRead", "TestControl", new { id = this.Model.Id }))
                                            .Create(create => create.Action("TestRead", "TestControl"))


    My Editor is in separate file names TestEditor.cshtml. I am able to add/edit records without any issues. I need to update only one column if it is existing record. Hence I am hiding the remaining fields (other than the one I am updating) in the editor window. So I was wondering if I can use the model's Id column to figure out if it is a new record or not.

    Here is my editor template : TestEditor.cshtml

    @model TestRecord

    // Render all the columns

    @if (this.Model.Id > 0)
        // only updated related column


  2. Milena
    Milena avatar
    257 posts

    Posted 10 Dec 2015 Link to this post


    Please navigate to the forum thread below, where the same problem is discussed:

    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
Back to Top