- I'm a rookie and just a little more than the basics.
- I have a Grid.View that shows me the records of a BBDD.
- I have a "document browser" that shows me one by one all the documents of the database and allows me to navigate among them.
- What I need is to limit the elements among which I want to navigate, that is, instead of browsing one by one through all the records, which can only be done among those that appear as a result of applying filters in the Grid. View.
What I want is that once a filter is applied, it is able to store in some way what the resulting elements are, in order to navigate only between those. For example, select only the records with the journal "002", and store them in a list, and then pass them to the controller of the individual view.
This is the grid code
@Html.Grid(Model).Columns(columns =>
{
columns.Add(c => c.num_diarC)
.Titled("Diario")
.SetWidth(60);
columns.Add(c => c.num_movC)
.Titled("Movimiento")
.SetWidth(60);
columns.Add(c => c.mes_diarC)
.Titled("Mes")
.SetWidth(60);
columns.Add(c => c.anno_diarC)
.Titled("Año")
.SetWidth(60);
columns.Add(c => c.codigoC)
.Titled("Código")
.SetWidth(70);
columns.Add(c => c.empresaC)
.Titled("Centro")
.SetWidth(60);
columns.Add(c => c.num_factC)
.Titled("Nº Factura")
.SetWidth(60);
columns.Add(c => c.fec_factC).Format("{0:d}")
.Titled("Fecha factura")
.SetWidth(100);
columns.Add(c => c.imp_factC).Format("{0:n} €")
.Titled("Importe")
.SetWidth(60);
columns.Add(c => c.nombreC)
.Titled("Empresa")
.SetWidth(70);
columns.Add()
.Encoded(false)
.Sanitized(false)
.SetWidth(200)
.RenderValueAs(c => Acciones(c));
}).WithPaging(BibliotecaDocu.src.Constantes.DISPLAY_DEFAULT_PAGE_SIZE).Sortable().Filterable(true).WithMultipleFilters().SetLanguage("es").EmptyText("No hay datos que mostrar").Named("filtrado")
And this one of the controller:
public ActionResult Buscar()
{
List<Compra> dbCompras = db.Compras.OrderByDescending(c => c.num_diar).ToList();
List<ModelCompra> compras = new List<ModelCompra>();
compras = new ModelCompra().getCompras(dbCompras);
return View(compras);
}
I've tried this:
@{
List<string> lista = new List<string>();
foreach (BibliotecaDocu.Models.ModelCompra compras in Model)
{
lista.Add(compras.num_factC);
}
}
But create a list with all the values because I'm referring to the model, and what I want is to make it to the Grid.