Grid: Support insert only

2 posts, 0 answers
  1. habeeb
    habeeb avatar
    8 posts
    Member since:
    Apr 2016

    Posted 06 May Link to this post

     

    How do I cause the MVC Grid to support insert only and no other operation. This is my code

     

    @(Html.Kendo().Grid<SomeViewModel>()
              .Name("SomeGrid")
                      .ToolBar(toolbar =>
                          {
                              toolbar.Create();
                              toolbar.Save();
                          })     
              .Columns(columns =>
              {
                  columns.Bound(p => p.Name).ClientTemplate(@"<input type='radio' name='SomeName'> #= Name # </input>");
                  columns.Bound(p => p.DateCreated);
                  columns.Command(command => { command.Edit(); });
              })
                      .Editable(editable => editable.Mode(GridEditMode.InCell))
              .Events(e => e.DataBound("onDataBound"))
              .Selectable(selectable => selectable.Enabled(true).Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
              .Scrollable()
              .Filterable()
              .HtmlAttributes(new { style = "height:200px;" })
              .DataSource(dataSource => dataSource
                  .Ajax()
                          .Batch(true)
                  .Events(events => events.Error("onError"))
                  .Model(model =>
                  {
                      model.Id(s => s.unique);
                      model.Field(s => s.DateCreated).Editable(false);
                  })
                  .Read(read => read.Action("GetSolutions", "Solutions"))               
                  .Create(create => create.Action("SomeAction", "SomeController"))
                  .Update(create => create.Action("SomeAction", "SomeController"))
                   
                   
                  ))

     

     

    Also, it looks like I have to implement the .Update method above even though I don't want to support updates. If I don't do that I get error "The update data binding setting is required by edit command".

     

    Ideally, it would have been nice to keep the update completely disassociated with inserting but looks like that's not the case and may be there has to be some hack to cause edit not to happen. Can someone please let me know this hack ?

  2. Marin
    Admin
    Marin avatar
    1043 posts

    Posted 09 May Link to this post

    Hello,

    You can hide the edit button as shown in this forum post:
    http://www.telerik.com/forums/grid-insert-and-delete-only-no-update-of-existing-records

    Regards,
    Marin
    Telerik
    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
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top