1
The two images are as mine array is. In the first image I have an array with 3 items, being the first of the month of April and contains 4 passages. For each passage I have the respective participants. My problem is in sending this array for my view, because I can’t get some properties at runtime like passagem.participante
.
I tried to split it three ways arrays, but when executed via foreach
on the screen is not displayed properly with the month and its participants with their tickets.
How to make an array only that I could access all the properties and play them on the screen?
Follow the view today, but I need to synchronize the information as I said before.
@using WebProvider.BMW_Incentivo.Domain.Models
@model WebProvider.BMW_Incentivo.Admin.Models.GerenciaPassagemModel
@{
ViewBag.Title = "Gerenciamento de Passagens";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/css/pageDataTables.css")" media="screen" />
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/css/tableDataTables.css")" media="screen" />
<script src="@Url.Content("~/Content/js/jquery.dataTables.js")" type="text/javascript"></script>
<script src="~/Content/js/pages/GerenciadorPassagem.js"></script>
@using (Html.BeginForm("Index", "GerenciaPassagem", FormMethod.Post))
{
<fieldset id="passagem">
<div style="float: left;">
<label>Mês:</label>
<select id="ListaPeriodo" name="ListaPeriodo" onchange="listaPassagensMes();">
@foreach (var item in Model.ListaPeriodo)
{
<option id="@item.Mes" value="@item.Mes">@item.DescricaoMes</option>
}
</select>
<span class="error">* Campo Obrigatório</span>
</div>
<div style="float: right;">
<label>Ano:</label>
<select id="ListaAno" name="ListaAno">
@*@foreach (int item in Model.Ano)
{*@
<option id="@Model.Ano " value="@Model.Ano "> @Model.Ano</option>
@*}*@
</select>
<span class="error">* Campo Obrigatório</span>
</div>
<table border="2" class="data display datatable" id="tabFiltra">
<thead>
<tr>
<th><span>Acao</span></th>
<th><span>Participante - CPF</span></th>
<th><span>Passagem</span></th>
<th><span>Status</span></th>
</tr>
</thead>
<tbody>
@foreach (Passagem participante in Model.ListaParticipante)
{
<tr>
<td>
<input type="checkbox" id="@participante.Id" name="idsCredito" value="participante.Acao" @(participante.Acao == true || participante.Acao == false ? "checked = 'checked' readonly='readonly' " : string.Empty) />
</td>
<td>
<label id="@participante.Participante.Id" for="participanteId"> @(participante.Passagens != null ? participante.Participante.NomeCompleto + " - " + participante.Participante.CPF : "") </label>
</td>
<td>
<label id="@participante.Passagens" for="participantePassagem">@(participante.Passagens.ToString() != "" ? participante.Passagens.ToString() : "") </label>
</td>
<td>
<label id="@participante.Acao" for="participanteAcao">@(participante.Acao == true ? "Aprovado" : participante.Acao == false ? "Recusado" : "-")</label>
</td>
</tr>
}
</tbody>
</table>
<br />
<br />
<br />
<br />
<br />
<br />
<input type="button" value="Aprovar" id="btAprovar" onclick="Aprovar(); return false;" onblur="Reload();" style="margin-left: 9px;" />
<input type="button" value="Recusar" id="BtRecusar" onclick="Reprovar(); return false;" style="margin-left: 9px;" />
</fieldset>
}
@section Scripts {
@Scripts.Render("~/bundles/knockout")
@Scripts.Render("~/bundles/jqueryui")
}
You’re sending as for view, nice post action and the view is easier to opine!
– user6026
Just so you know
IEnumerable<Periodo>
is the collection responsible for the data including related?– user6026
Yes, this collection I have all the data I need to display on the screen...
– SirSmart
So at View on
@model
put it like this: Put@model IEnumerable<Periodo>
... so you can access all items by this collection ...– user6026
When I did this, it returned errors in the properties saying that the methods were not defined, example: Model.periodo. You opened up properties for me to use for example, but you wouldn’t know how to do that... could you please help me
– SirSmart