Grid batch updating with Web API

4 posts, 0 answers
  1. Donna Stewart
    Donna Stewart avatar
    127 posts
    Member since:
    Apr 2009

    Posted 12 Nov 2014 Link to this post

    I have a grid in which I would like to use batch editing.  However, the update is not working - I am seeing no data when I hit the Web API controller.  I have read the Web API editing document on the Kendo site and I have looked at the example application in the download of UI for ASP.NET MVC.  I have Googled and searched these forums. I can find no example of batch editing using Web API without OData.  I am not using OData.  If anyone can be of assistance, I would be so very appreciative!  I can get inline editing to work, no problem.  But I would really like to use batch editing.
    I have attached a couple of screen shots showing the empty parameter on my controller method and the request header and data from the Web API call.

    Here is my code:

        .Columns(columns =>
            columns.Bound(c => c.Id).Hidden();
            columns.Bound(c => c.UserFName).Title("First Name");
            columns.Bound(c => c.UserLName).Title("Last Name");
            columns.Bound(c => c.UserName);
            columns.Bound(c => c.PasswordHash).Hidden();
            columns.Bound(c => c.Email);
            columns.Template(@<text></text>).ClientTemplate("<input type='checkbox' #= IsBIUser ? checked='checked':'' # class='chkbx' />").Width(100).Title("BI User");
            columns.Bound(c => c.StartDate).Format("{0:MM/dd/yyyy}");
            columns.Bound(c => c.EndDate).Format("{0:MM/dd/yyyy}");
            columns.Bound(c => c.UserKey).Hidden();
        .ToolBar(toolbar => toolbar.Save())
        .Editable(ed => ed.Mode(GridEditMode.InCell))
        .Pageable(pageable => pageable
        .DataSource(dataSource => dataSource
            .Model(model => model.Id(c => c.Id))
            .Read(read => read.Url("/api/gmcmembership/au/11712").Type(HttpVerbs.Get))
            .Update(update => update.Url("/api/gmcmembership/uu").Type(HttpVerbs.Put))

    WebAPI Controller code for update:
    /// <summary>
    /// Updates user(s) in GMCMembership System with changes made in Kendo Grid
    /// </summary>
    /// <param name="users"></param>
    /// <remarks> </remarks>
    public HttpResponseMessage UpdateUsers([Bind(Prefix = "models")]IEnumerable<UserGridModel> users )
            using (
                var um = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()))
                foreach (var user in users)
                    var id = user.Id;
                    var userToUpdate = new ApplicationUser();
                    userToUpdate = um.Users.SingleOrDefault(u => u.Id == id);
                    if (userToUpdate != null)
                        userToUpdate.Email = user.Email;
                        userToUpdate.EndDate = (DateTime)user.EndDate;
                        userToUpdate.IsBIUser = user.IsBIUser;
                        userToUpdate.StartDate = (DateTime)user.StartDate;
                        userToUpdate.UserFName = user.UserFName;
                        userToUpdate.UserLName = user.UserLName;
                        userToUpdate.UserName = user.UserName;
            return Request.CreateResponse(HttpStatusCode.OK);
        catch (Exception ex)
            return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);


  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 14 Nov 2014 Link to this post

    Hi Donna,

    We are not sure if Web API supports batch updates. For example the signature for updating a record is something like

    public HttpResponseMessage Put(int id, Model model)

    We don't know if it is possible to make it accept a collection of models.

    Still you can use InCell edit mode with Web API but you have to disable batch updates. The grid will make separate HTTP requests for every change and work as expected.

    Atanas Korchev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. UI for ASP.NET AJAX banner
  4. Donna Stewart
    Donna Stewart avatar
    127 posts
    Member since:
    Apr 2009

    Posted 14 Nov 2014 in reply to Atanas Korchev Link to this post

    Hi Atanas,

    Thank you for your response.  I guess I didn't realize you could do InCell editing with batch mode turned off.  I have already changed my code to use the MVC controller for my grid, so all works great now.  If I have time, I may go back and change to use the InCell  editing with batch mode disabled and try with the Web Api controller again.

    Thanks again for your help,
  5. Robert
    Robert avatar
    14 posts
    Member since:
    Feb 2014

    Posted 03 Nov 2015 in reply to Atanas Korchev Link to this post

    Is this still the case?  I am converting to WebApi and I have several grids that use Batch editing.  
Back to Top
UI for ASP.NET AJAX banner