1
I’m already displaying a table in Index, only I want to display another table from the same controller. I created a PartialView
calling for PartCorteCabos()
and created a view of it. I tried to make the call using @Html.Partial()
, but does not display the information coming from the database. How do I display the second table?
Controller
public class DashboardSPMController : Controller
{
DashboardSPMRepository dashRepository = new DashboardSPMRepository();
public ActionResult Index()
{
return View(dashRepository.InfoReceb());
}
public ActionResult PartCorteCabos()
{
return PartialView(dashRepository.InfoCorteCabos());
}
}
Partcortecabos (Partial View)
@model IEnumerable<WAM.Areas.Monitoramentos.Models.Entities.DashboardSPM>
@Html.Grid(Model).Columns(column =>
{
column.Add(x => x.prioridade_cc).Titled("Prioridade");
column.Add(x => x.sales_order_cc).Titled("SO's");
column.Add(x => x.delivery_cc).Titled("Delivery");
column.Add(x => x.material_cc).Titled("P/N");
})
Index View
@model IEnumerable<WAM.Areas.Monitoramentos.Models.Entities.DashboardSPM>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/Master.cshtml";
}
<div>
<span class="titulo">
<p>Status Recebimento</p>
</span>
<span class="size-tab">
@Html.Grid(Model).Columns(column =>
{
column.Add(x => x.material).Titled("Itens 902");
column.Add(x => x.lead_time).Titled("LT");
column.Add(x => x.lotes_nac).Titled("Lote Nacional");
column.Add(x => x.lotes_imp).Titled("Lote Importado");
column.Add(x => x.sb).Titled("SB's");
column.Add(x => x.danfe).Titled("DANFE's");
})
</span>
</div>
<div>
<span class="titulo">
<p>Corte Cabos</p>
</span>
@Html.Partial("PartCorteCabos")
</div>
How do not display values coming from the bank ? pass the model to your view ?
– Marcos Brinner
In the first 'div' the data is displayed normally. But in the second 'div' the data is not displayed, only the column name appears but the data does not appear.
– Guilherme Wayne
@Marcosbrinner managed to make it display. I changed the shape I was calling Partialview. Instead of calling it that way @Html.Partial("Partcortecabos"), which is the form in the top code, I called it @Html.Action ("Partcortecabos").
– Guilherme Wayne
The model declared in Partial should not be of the same type received in
InfoCorteCabos()
? I see that in the controller you have two different methods and in the views you are indicating the same model– Leandro Angelo
The data is inside only one Model that is Dashboardspm
– Guilherme Wayne
But both methods,
dashRepository.InfoReceb()
anddashRepository.InfoCorteCabos()
return aDashboardSPM
? Include her structure in the question– Leandro Angelo
Yes, both return a Dashboarsspm. I do not know if the way I did was the best, I think not, because I am still learning. But it solved my problem. If you have a better way to display the data, I would like to know to learn.
– Guilherme Wayne
It wouldn’t be ideal for you to call a Renderaction(Controlleraction) in your view, where your controller would be responsible for returning to Controlleraction with your model?
– Victor Laio