Grid: Support insert only

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

    Posted 06 May 2016 Link to this post


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


                      .ToolBar(toolbar =>
              .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))
              .HtmlAttributes(new { style = "height:200px;" })
              .DataSource(dataSource => dataSource
                  .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
    Marin avatar
    1057 posts

    Posted 09 May 2016 Link to this post


    You can hide the edit button as shown in this forum post:

    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