GridEditMode.InLine after Edit then Update - Grid Stays In Edit Mode

8 posts, 1 answers
  1. Bill
    Bill avatar
    75 posts
    Member since:
    Feb 2013

    Posted 09 Apr 2013 Link to this post

    Title says it all.  I am editing a record inline.  When I hit update, the request to the server occurs, the record is saved and the response is returned.  However, the Grid does not acknowledge the fact that the AJAX request was successful.  So the Grid stays in edit-mode.  If I cancel then refresh the grid, the row shows up as it should (saved).  No errors are occurring on the server or client.

    I'm using the ASP.NET MVC Wrappers - AJAX.

    <div style="width: 700px">
        @(Html.Kendo().Grid<RoleGridModel>()
            .Name("grdRoles")
            .Columns(columns =>
            {
                columns.Bound(r => r.Name).Width(200);
                columns.Bound(r => r.Description).Width(300);
                columns.Command(command => {
                    if (security.CanAdd || security.CanUpdate) command.Edit();
                    if (security.CanDelete) command.Destroy();
                }).Width(200);
            })
            .Groupable(grouping => grouping
                .Enabled(false))
            .Events(events => { if (security.CanAdd && !security.CanUpdate) events.DataBound("function() { this.table.find('.k-grid-edit').hide(); }"); })
            .DataSource(dataSource => dataSource
                .Ajax()
                .Model(model => model.Id(r => r.RoleId))
                .Events(events => events.Error("error_handler"))
                .Read(read => read.Action("Index", "Roles", new { area = "Setup" }))
                .Create(create => create.Action("Create", "Roles", new { area = "Setup" }))
                .Update(update => update.Action("Edit", "Roles", new { area = "Setup" }))
                .Destroy(destroy => destroy.Action("Delete", "Roles", new { area = "Setup" }))
                .Sort(sort => sort.Add(r => r.Name).Ascending())
                .PageSize(10))
            .Filterable(filtering => filtering
                .Enabled(true))
            .Editable(editable => editable.Mode(GridEditMode.InLine))
            .Pageable(paging => paging
                .Enabled(true)
                .Info(true)
                .PageSizes(false)
                .Refresh(true))
            .Scrollable(scrolling => scrolling
                .Enabled(false)
                .Height(400)
                .Virtual(false))
            .Sortable(sorting => sorting
                .Enabled(true)
                .AllowUnsort(false)
                .SortMode(GridSortMode.SingleColumn))
            .ToolBar(toolbar => { if (security.CanAdd) toolbar.Create(); })
        )
    </div>

    [HttpPost]
    public ActionResult Edit([DataSourceRequest] DataSourceRequest request, RoleGridModel model)
    {
        if (ModelState.IsValid && model != null)
        {
            try
            {
                Role r = Mapper.Map<RoleGridModel, Role>(model);
                r.AppContext = this.AppContext;
                r.SubscriberId = this.AppContext.SelectedSubscription.SubscriberId;
                r.SubscriptionId = this.AppContext.SelectedSubscription.SubscriptionId;
                r.ModifyDate = DateTime.UtcNow;
                r.IsNew = false;
                r.IsMarkedForDelete = false;
                r.HasChanges = true;
                r.Save();
            }
            catch (Exception ex)
            {
                LogException(ex);
                ModelState.AddModelError("", "Unable to update role. " + ex.Message);
            }
        }
     
        return Json(ModelState.ToDataSourceResult());
    }
  2. Answer
    Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 11 Apr 2013 Link to this post

    Hi Bill,

    Basically there is a breaking change with the new version of jQuery which affects the Kendo Q1 2013 version 2013.1.319  - for more information about how to proceed I would suggest to check this help article in our forums.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Bill
    Bill avatar
    75 posts
    Member since:
    Feb 2013

    Posted 11 Apr 2013 Link to this post

    Thank you Vladimir.  That was the answer I needed.

    I will be using the following on update and destroy server responses until an official update is released to fix the issue.
    return Json(ModelState.IsValid ? new object() : ModelState.ToDataSourceResult());

  5. Jan Kaare
    Jan Kaare avatar
    16 posts
    Member since:
    Dec 2010

    Posted 14 Apr 2013 Link to this post

    This post is to be deleted as the problem described was caused by MySQL queries mismatches...
    How to delete this post?


    I have the same problem utilizing the PHP wrapper.

    When a new record is added, the data is saved to database in behind the scene, but grid stays in edit mode until page is refreshed...

    How to fix this for the PHP wrapper mechanism?
  6. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 15 Apr 2013 Link to this post

    Hi Bill, 

     
    Your question about PHP wrappers is not related to the original topic of this support conversation, so please submit a new support ticket for it. In this way you can be sure that your query will reach the corresponding staff member in time and will be answered faster and accurately.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  7. Ken Lewis
    Ken Lewis avatar
    28 posts
    Member since:
    Sep 2009

    Posted 14 May 2013 Link to this post

    Bill & Vladimir,

    Thanks for your posts. I had exactly the same issue and you saved me a lot of time!

    Ken
  8. guga
    guga avatar
    11 posts
    Member since:
    Mar 2012

    Posted 05 Jun 2013 Link to this post

    I did your workaround and it works but the object inside the grid is not updated, I think it is because we are returning an empty object... any idea?
  9. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 07 Jun 2013 Link to this post

    Hi Gustavo,

     
    From the provided information it's not clear for us what is the exact reason for this behavior - could you please open a new support thread with more information about the current setup that you have? This would help us pinpoint the exact reason for this behavior.

    Kind Regards,
    Vladimir Iliev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready