Complementing the response of the Gypsy, to work in my scenario I had to make some changes.
First, I created Action :
public ActionResult Ordenar(String status, int? pagina)
{
var lista = db.Ocorrencias.Where(o => o.Status == status).Include(o => o.Aluno).ToList();
int paginaTamanho = 10;
int paginaNumero = (pagina ?? 1);
return View(lista.ToPagedList(paginaNumero, paginaTamanho));
}
Then I created a PartialView of that Action :
<h3>Busca por Status</h3>
<div class="alert-info">
<form action="/Ocorrencias/Ordenar" id="status">
Ordenar por:
<input type="radio" name="status" value="Pendente" onclick="myFunction()">Pendente
<input type="radio" name="status" value="Resolvido" onclick="myFunction()">Resolvido
</form>
</div>
<table class="table table-striped">
<tr>
<th>
Nome do Aluno
</th>
<th>
Status
</th>
<th>
Data de Entrada
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Aluno.NomeAluno)
</td>
<td>
<input type="text" name="Status" id="Status" value="@Html.DisplayFor(modelItem => item.Status)" readonly class="Status" />
</td>
<td>
@Html.DisplayFor(modelItem => item.DataOcorrencia)
</td>
<td>
<a href="~/Ocorrencias/[email protected]" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-edit"></span></a>
<a href="~/Ocorrencias/[email protected]" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-list"></span></a>
<a href="~/Ocorrencias/[email protected]" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove"></span></a>
</td>
</tr>
}
</table>
Página @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) de @Model.PageCount
@Html.PagedListPager(Model, pagina => Url.Action("Ordenar", new { pagina, filtro = ViewBag.Filtro }))
//Esse *script* faz com que o *radio* tenha o mesmo comportamento de um *button*
<script>
function myFunction() {
document.getElementById("status").submit();
}
</script>
And to make the filter work perfectly, I put a form in my view Index, which calls Action Controller Occurrences.
//Demais controles da minha *view*
//Note no atributo *action* do *form* que chamo a *action* que será usada
<form action="/Ocorrencias/Ordenar" id="status">
Ordenar por:
<input type="radio" name="status" value="Pendente" onclick="myFunction()">Pendente
<input type="radio" name="status" value="Resolvido" onclick="myFunction()">Resolvido
</form>
//O restante dos controles
//Esse *script* faz com que o *radio* tenha o mesmo comportamento de um *button*
<script>
function myFunction() {
document.getElementById("status").submit();
}
</script>
And that's how it worked for me.