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

Kendo Grid intermittantly will not hit the controller on an edit

2 Answers 218 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 1
Danny asked on 10 Mar 2015, 03:12 PM
Hello,

I am having an issue with a couple of Kendo grids on our Mvc project. I was on an older version of Kendo, and I thought upgrading to the latest might help, but after upgrading the problem remained the same. What happens is sometimes when I edit a row in the grid, the action will not get hit in the controller at all. When I first load the application, the first couple of edits will often go through (but not always), however once it stops working, it'll never work again until the page has been refreshed (but usually it requires the whole application to be reset). It's been very hard to pin down because no errors are getting thrown in either javascript or asp.net.

We are using a custom template for editing, but I have eliminated this as a possible culprit, because the problem occurs exactly in the same way if I change the edit type to InCell or InLine.

Here is the code:

    @(Html.Kendo().Grid<AttorneyRequestPendingDeterminationViewModel>()
          .Name("PendingDeterminationGrid")
          .DataSource(dataSource => dataSource
              .Ajax()
              .Events(events => events.Error("onError"))
              .Read(read => read.Action("Read", "PendingDetermination").Data("getSearchData"))
              .Model(model => model.Id(p => p.Id))
              .Update(read => read.Action("DecisionsEdit", "PendingDetermination"))
              .Update(read => read.Type(HttpVerbs.Post))
              .PageSize(20)
              .Events(events => events.RequestEnd("onRequestEnd"))
          )
          .Columns(columns =>
          {
              columns.Bound(m => m.DateEntered).Title("Date Entered");
              columns.Bound(m => m.LocalId).Title("Local ID");
              columns.Bound(m => m.DefendantName).Title("Name");
              columns.Bound(m => m.Offense).Title("Offense");
              columns.Bound(m => m.EnteredBy).Title("FQ User ID");
              columns.Bound(m => m.InterviewLocation).Title("Interview Location");
              columns.Bound(m => m.CourtLocation).Title("Court Location");
              columns.Bound(m => m.Recommendation).Title("Recommendation");
              columns.Command(m => m.Edit()).Title("Actions");
          })
          .Editable(edit => edit.Mode(GridEditMode.PopUp).TemplateName("DecisionsTemplate"))
              .Sortable(sortable => sortable
                .Enabled(true)
                .AllowUnsort(false)
                .SortMode(GridSortMode.SingleColumn))
              .Groupable()
              .Pageable()
          .Deferred()
          )

<script type="text/javascript">
    require(['/Content/js/config.js'], function() {
        require(['jquery', 'lib/kendo/kendo.grid.min', 'lib/kendo/kendo.aspnetmvc.min'], function($, kendogrid, kendomvc) {
            @Html.Kendo().DeferredScriptsFor("PendingDeterminationGrid", false)

            function onRequestEnd(e) {
                if (e.type == "update") {
                    location.reload();
                }
            }

            $(".k-link").bind("click", function(e) {
                $('#grid').data('kendoGrid').dataSource.page(1);
            });

            $('#SearchString').keyup(function(event) {
                if (event.keyCode == 13) {
                    $('#SearchButton').click();
                }
            });

            $("#SearchButton").click(
                function() {
                    $('#grid').data('kendoGrid').dataSource.fetch();
                    $('#grid').data('kendoGrid').dataSource.page(1);
                });

            function getSearchData() {
                return {
                    SearchString: $("#SearchString").val(),
                    SearchTypeSelected: $("#SearchTypeSelected").val(),
                };
            };
        });
    });
</script>


And the controller method in case you need it:

[HttpPost]
        public ActionResult DecisionsEdit([DataSourceRequest] DataSourceRequest request,
            AttorneyRequestPendingDeterminationViewModel attorneyRequest)
        {
            string href =
                attorneyRequest.Links.FirstOrDefault(l => l.Rel == Constants.Rels.AttorneyRequestDecisions).Href;
            int val;
            if (attorneyRequest.EligibilityOverrideReason != null && int.TryParse(attorneyRequest.EligibilityOverrideReason.Value, out val))
            {
                attorneyRequest.EligibilityOverrideReasonId = val;
            }
            if (attorneyRequest.NotEligibleReason != null && int.TryParse(attorneyRequest.NotEligibleReason.Value, out val))
            {
                attorneyRequest.NotEligibleReasonId = val;
            }


            var response = HalClient.PutAsJsonAsync(href, attorneyRequest).Result;

            if (!response.IsSuccessStatusCode)
            {
                if (response.StatusCode == HttpStatusCode.NotFound)
                {
                    this.Toast(ToastType.Error, "The attorney request could not be located");
                }
                if (response.StatusCode == HttpStatusCode.BadRequest)
                {
                    this.Toast(ToastType.Error, "The attorney request is invalid");
                }
            } else
            {
                this.Toast(ToastType.Success, "The decisions have been updated");
            }
            return Index();
        }

Please let me know if you need any other information to help nail this down.



2 Answers, 1 is accepted

Sort by
0
Danny
Top achievements
Rank 1
answered on 10 Mar 2015, 06:29 PM
Update: Edit seems to work 100% on Firefox, but it is intermittent in both Chrome and IE.
0
Alexander Popov
Telerik team
answered on 12 Mar 2015, 11:53 AM
Hello Danny,

I already addressed this query in a support ticket #914819.

Regards,
Alexander Popov
Telerik
 

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.

 
Tags
Grid
Asked by
Danny
Top achievements
Rank 1
Answers by
Danny
Top achievements
Rank 1
Alexander Popov
Telerik team
Share this question
or