How to do reload asp.net mvc pagedlist?

1

I have my grid with the haged Pagedlist helper

<div class="table-responsive">
    <table class="table table-hover">
        <tr>
            <th>
                @Html.ActionLink("Id", "Index", new { OrderBy = ViewBag.OrdenaPorId, FiltroPagina = ViewBag.FiltroPagina })
            </th>
            <th>
                @Html.ActionLink("Nome", "Index", new { OrderBy = ViewBag.OrdenaPorNome, FiltroPagina = ViewBag.FiltroPagina })
            </th>
            <th>
                @Html.ActionLink("Descrição", "Index", new { OrderBy = ViewBag.OrdenaPorDescricao, FiltroPagina = ViewBag.FiltroPagina })
            </th>
            <th></th>
        </tr>

        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Id)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Nome)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Descricao)
                </td>
                <td style="text-align:right;">
                    @Html.ActionLink("Editar", "Editar", new { id = item.Id }, new { @class = "btn btn-primary" })
                    <button class="btn btn-danger" onclick="deletar(@item.Id)">Deletar</button>
                </td>
            </tr>
        }

    </table>
</div>

<br />
Página @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) de @Model.PageCount
@Html.PagedListPager(Model, Pagina => Url.Action("Index", new { Pagina, Orderby = ViewBag.AtualOrder, FiltroPagina = ViewBag.FiltroPagina }))

When you click delete, it opens a modal, and it makes a post for the delete action

But here comes the problem,

If error occurs, you should return the error message, otherwise I need a "reload" on my grid

The error message, ok, but what about reload? how do I use PagedList?

                  $.ajax({
                        url: "Deletar",
                        type: "POST",
                        data: { Id: Id},
                        success: function (data) {
                            //Como faço o reload aqui?
                        },
                        error: function (data) {
                            //Mensagem de erro
                        }
                    });
    
asked by anonymous 25.08.2014 / 14:53

1 answer

1

If Controller has been implemented as in this answer , the following Ajax should resolve:

$.ajax({
    url: "Deletar",
    type: "POST",
    data: { Id: Id},
    success: function (data) {
        window.location.reload(true);
    },
    error: function (data) {
        //Mensagem de erro
    }
});
    
25.08.2014 / 16:14