Kendo Grid intermittantly will not hit the controller on an edit

3 posts, 0 answers
  1. Danny
    Danny avatar
    6 posts
    Member since:
    Jul 2014

    Posted 10 Mar 2015 Link to this post

    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. Danny
    Danny avatar
    6 posts
    Member since:
    Jul 2014

    Posted 10 Mar 2015 in reply to Danny Link to this post

    Update: Edit seems to work 100% on Firefox, but it is intermittent in both Chrome and IE.
  3. Alexander Popov
    Admin
    Alexander Popov avatar
    1443 posts

    Posted 12 Mar 2015 Link to this post

    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.

     
Back to Top