Empty grid after update or insert

Mar 5, 2013 at 11:56 PM
Edited Mar 5, 2013 at 11:59 PM
Hi Tomasz.

I'm having problems with a grid remains empty after editing or editing a row.
I have reviewed with firebug any errors but everything seems fine.
This is my scenario:
This is my view (called Factura.cshtml)
@using Lib.Web.Mvc.JQuery.JqGrid;
@model Estudio.WebUI.Models.FacturaViewModel
@{        
      Layout = "~/Views/Shared/_Layout.cshtml";
      var grid = new JqGridHelper<Estudio.WebUI.Models.FacturaLineaView>("Detalle",
                      dataType: JqGridDataTypes.Json,
                      methodType: JqGridMethodTypes.Post,
                      pager: true,
                      rowsList: new List<int> { 10, 15, 20, 25, 30 },
                      parametersNames: new JqGridParametersNames { Id = "DetalleFacturaId" },
                      width: 800,
                      sortingName: "LineaId",
                      sortingOrder: JqGridSortingOrders.Asc,
                      url: Url.Action("ListDetalle", new { id = Model.FacturaId }),
                      viewRecords: true
        ).Navigator(new JqGridNavigatorOptions { Search = false },
    addActionOptions: new JqGridNavigatorEditActionOptions { Url = Url.Action("EditDetalle"), CloseAfterEdit = true, ClearAfterAdd = true, Width = 400, ExtraDataScript = "{FacturaId : $('#FacturaId').val() }", ReloadAfterSubmit = true},
    editActionOptions: new JqGridNavigatorEditActionOptions { Url = Url.Action("EditDetalle"), CloseAfterEdit = true, ClearAfterAdd = true, Width = 400, ExtraDataScript = "{FacturaId : $('#FacturaId').val() }", ReloadAfterSubmit = true },
    deleteActionOptions: new JqGridNavigatorDeleteActionOptions { Url = Url.Action("DeleteDetalle") });
}
@section JavaScript {
    <script type="text/javascript">
        $(document).ready(function() {
            @grid.GetJavaScript()
        });
    </script>
} 
@using (Html.BeginForm())
{
....
        @grid.GetHtml()
....
}
This is my EditDetalle Action Result
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult EditDetalle(FacturaLineaView viewModel)
        {
            .... update or add new record to database
            return Editar(viewModel.FacturaId);
        }
This is my Editar Action Result
        public ActionResult Editar(int facturaId)
        {
           ..... fill my data model......
            return View("Factura", model);
        }
I have also the ListDetalle ActionResult that is responsible for returning JqGridJsonResult

Maybe my mistake is in the way of calling the view, but I can not do better recoating as things.
As I mentioned the error occurs after upgrading the grid data to return to the Factura view, the grid remains empty despite having data.
Coordinator
Mar 6, 2013 at 7:24 PM
Hi,

There are two things that are very confusing in your scenario.

First thing is that you have put the grid into the form. This shouldn't cause any issues but it also doesn't provide anything and might lead to some "complicated" markup.

Second thing is returning View from your edit action. JqGrid form editing module is making standard AJAX request and it is not expecting an HTML in response. The module might have issues with interpreting the response and decide that the update/insert have failed.
Mar 8, 2013 at 9:07 PM
TPeczek wrote:
Hi,

There are two things that are very confusing in your scenario.

First thing is that you have put the grid into the form. This shouldn't cause any issues but it also doesn't provide anything and might lead to some "complicated" markup.

Second thing is returning View from your edit action. JqGrid form editing module is making standard AJAX request and it is not expecting an HTML in response. The module might have issues with interpreting the response and decide that the update/insert have failed.
Great, i try to review my code.