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

Grid: Support insert only

1 Answer 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
habeeb
Top achievements
Rank 1
habeeb asked on 06 May 2016, 09:39 PM

 

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 ?

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 09 May 2016, 08:41 AM
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
Tags
Grid
Asked by
habeeb
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or