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

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

7 Answers 675 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 09 Apr 2013, 09:02 PM
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());
}

7 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 11 Apr 2013, 09:39 AM
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!
0
Bill
Top achievements
Rank 1
answered on 11 Apr 2013, 01:41 PM
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());

0
Jan Kaare
Top achievements
Rank 2
answered on 14 Apr 2013, 11:45 AM
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?
0
Vladimir Iliev
Telerik team
answered on 15 Apr 2013, 06:36 AM
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!
0
Ken Lewis
Top achievements
Rank 1
answered on 14 May 2013, 09:40 PM
Bill & Vladimir,

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

Ken
0
guga
Top achievements
Rank 1
answered on 05 Jun 2013, 06:03 PM
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?
0
Vladimir Iliev
Telerik team
answered on 07 Jun 2013, 08:31 AM
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!
Tags
Grid
Asked by
Bill
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Bill
Top achievements
Rank 1
Jan Kaare
Top achievements
Rank 2
Ken Lewis
Top achievements
Rank 1
guga
Top achievements
Rank 1
Share this question
or