0

I'm working with ASP.Net MVC4, jquery, razor In my view I use webgrid, I have an action "Anular" but when execute this action not reload o refresh the webgrid, how I can resolve this problem? this is my code, the controller updates the field but when he returns to the view does not refresh data

function Anular(IdInspeccion, IdSolicitud, Estado) {
var MsgEstado;
    (Estado == 'C') ? MsgEstado = 'Concluir' : MsgEstado = 'Anular';
    var Mensaje = confirm("Esta seguro que desea " + MsgEstado + " la Inspeccion: "+ IdInspeccion +"?");
    if (Mensaje) {
        $.ajax({
            type: 'POST',
            url: '@Url.Action("Anular", "raMainInspeccion")',
            data: JSON.stringify({ IdIns: IdInspeccion, IdSol : IdSolicitud, Est : Estado }),
            contentType: 'application/json; charset=utf-8',
            dataType: "json",
            success: function (data) {                    
            },
        });
    }
}

@{        
    var CotInp = new WebGrid(Model, canPage: true, rowsPerPage: 15, selectionFieldName: "selectedRow", ajaxUpdateContainerId: "gridContent");
    CotInp.Pager(WebGridPagerModes.NextPrevious);        
}    
<div id="gridContent">
@CotInp.GetHtml(tableStyle: "gridtable",
    headerStyle: "gridhead",
    alternatingRowStyle: "gridaltRow",
    selectedRowStyle: "gridselectRow",
    footerStyle: "gridfooter",
    columns: CotInp.Columns(
            CotInp.Column("is_idsolicitud", "Solicitud", format: @<text>@item.is_idsolicitud</text>),
            CotInp.Column("is_idcotizacion", "Cotizacion", format:@<text>@item.is_idcotizacion</text>),                
            CotInp.Column("pri_parestadoinsp", "Estado", format: @<text>@item.pri_parestadoinsp</text>),                
            CotInp.Column("", style: "description",
                header: "Anular",format: (itemAnu) =>
                (bool)string.IsNullOrEmpty(itemAnu.pri_idinspeccion)
                ? new HtmlString("")
                : new HtmlString(Html.Raw("<input name='submit' id='submitme' type='image' src='" + @Url.Content("~/content/images/gridanular.png") + "' onclick=\"Anular('" + itemAnu.pri_idinspeccion.ToString() + "','" + itemAnu.is_idsolicitud.ToString() + "','A')\"/>").ToString())                    
            )
     )
 )
 </div>

    /* change the field "Estado" */
    public ActionResult Anular(string IdIns, string IdSol, string Est)
    {
        string Mensaje = "";
        Models.PreInspecciones cInspeccion = new Models.PreInspecciones();
        cInspeccion.pri_idinspeccion = IdIns;
        cInspeccion.pri_partipoinsp = "L";
        cInspeccion.pri_parestadoinsp = Est;
        cInspeccion.pri_idsolicitud = Convert.ToInt32(IdSol);
        Servicio.SaveTable<Models.PreInspecciones>("crdsis.pre_inspecciones", cInspeccion.getPk(), cInspeccion, cInspeccion, ref Mensaje);
        List<string> Param2 = new List<string>();
        Param2.Add("AC");
        List<Models.PreInformacionProIns> ProInp = Servicio.RetornaDatosFuncion<Models.PreInformacionProIns>(ref Mensaje, "crdsis.f_get_listadoproins", Param2, null);
        return PartialView("~/Areas/Inspeccion/Views/raMainInspeccion/Index.cshtml", ProInp);            
    } 
raranibar
  • 1,247
  • 4
  • 23
  • 44
  • a webgrid renders as a table in the html. An ajax call doesn't refresh the page. If you want the table to refresh you need to pass the updated value back to the view and update the desired information manually with jquery – Matt Bodily Jan 24 '14 at 22:34
  • or you can put the webgrid into a partial view and refresh the partial as part of your ajax call – Matt Bodily Jan 24 '14 at 22:35

0 Answers0