grid inline editing with dynamic model

2 posts, 0 answers
  1. Dinesh
    Dinesh avatar
    3 posts
    Member since:
    Oct 2014

    Posted 05 Jun 2015 Link to this post

     I have a dynamic model below is the cshtml code, is line editing possible with dynamic model ? 
     
    @(Html.Kendo().Grid<dynamic>()
                  .Name("requestCapacity")
                  .Columns(columns =>
                  {
                      foreach (var c in Model)
                      {
                          if (c.Equals("Week Starting"))
                              columns.Template(@<text> </text>).ClientTemplate(@"<span class='k-widget k-datepicker' style='width: 150px;'><span class='k-picker-wrap k-state-default'><input id='datepicker'  style='width: 100%;' data-role='datepicker' type='text' class='k-input' role='combobox' aria-expanded='false' aria-owns='datepicker_dateview' aria-disabled='false' aria-readonly='false' aria-activedescendant='270cfa37-b189-46a8-b0ea-857df06f84ab_cell_selected'><span unselectable='on' class='k-select' role='button' aria-controls='datepicker_dateview'><span unselectable='on' class='k-icon k-i-calendar'>select</span></span></span></span>").Width(150).Title(c.Key);
                          else
                              columns.Template(@<text>c</text>).Title(c.Key);
     
                      }
                      columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
                  }
          )
                  .Editable(editable => editable.Mode(GridEditMode.PopUp))
                      .HtmlAttributes(new { style = "height:auto;width:85%;align:center;margin:0 auto" })
                      .Pageable()
                      .ToolBar(toolbar => toolbar.Create().Text("Add"))
                  .Sortable()
                  .Scrollable().EnableCustomBinding(true)
                   .DataSource(dataSource => dataSource
                          .Ajax().Model(model =>model.Id("ID")
                          )
                      .PageSize(10)
                        .Events(events => events.Error("error_handler"))
                                       .Create(update => update.Action("EditingInline_Update", "RequestCapacity",new {testing="#=dataItem#"}).Type(HttpVerbs.Post))
                              .Read(read => read.Action("PopulateRequest", "RequestCapacity").Type(HttpVerbs.Post))
                                      .Update(update => update.Action("EditingInsline_Update", "RequestCapacity","#=dataItem#").Type(HttpVerbs.Post))
                              .Destroy(update => update.Action("EditingInline_Destroy", "Capacity"))
                  )
    )

     

    controller code.

    public ActionResult RequestCapacityPopUp()<br>        {<br>            var dynamicBinding = new List<string>(){"Week Starting"};<br>            using (var dataModel = new CapacityPlannerEntities())<br>            {<br>                foreach (var team in dataModel.Teams)<br>                {<br>                    dynamicBinding.Add(team.TeamName);<br>                }<br>            }<br>            return View(dynamicBinding);<br>        }

  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 09 Jun 2015 Link to this post

    Hi Dinesh,

    Although not supported out of the box, this could be achieved using a custom implementation. I would suggest checking the following forum threads, where this topic is discussed:

    Regards,
    Alexander Popov
    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
Back to Top