How to do Reload Asp.net mvc pagedlist?

Asked

Viewed 279 times

1

I have my grid with the html helper Pagedlist

<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 }))

By clicking delete, it opens a modal, and the same makes a post to delete action

But here comes the problem,

If there is an error, 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
                        }
                    });

1 answer

1


If the Controller was implemented as in this answer, the following Ajax must resolve:

$.ajax({
    url: "Deletar",
    type: "POST",
    data: { Id: Id},
    success: function (data) {
        window.location.reload(true);
    },
    error: function (data) {
        //Mensagem de erro
    }
});
  • well that Gypsy, worked, thanks, taking advantage, know some responsive grid to indicate? I am suffering with my choices lately, rsrs

  • @Rod Which one are you using? What exactly do you imagine as responsive?

  • I’m using the same pagedlist, responsive only that does not break in the layout

  • Combined use of Bootstrap for Views, or the Zurb Foundation, but the Foundation requires more manual work.

  • but what about your data grid? datagrid, which one uses?

  • This: http://www.datatables.net/

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.