0
Briefly:
I have a screen with a table
populated by the list below, where I select the line through checkbox
, I need to pass this list to my actionResult
.
As I do not have a form on this screen I can not give Ubmit the data to pass to actionResult
.
Viewmodel used in html with the list property
public class DeliveryServiceListViewModel
{
public List<DeliveryServiceViewModel> DeliveryServices { get; set; }
}
ActionResult
:
public ActionResult EditAll()
{
}
Which I call that I don’t know if it’s the right one:
<button onclick="location.href='@Url.Action("EditAll", "DeliveryService")'">
Salvar
</button>
- How to pass the list to me on
controller
? - It has as I pass only the list or I have to pass all the Viewmodel that contains the list?
I tried to pass the list using new { DeliveryServices = Model.DeliveryServices }
, but she arrives at controller
empty.
@model Dlieve.BackOffice.Areas.BackOffice.Models.DeliveryServiceListViewModel
<table class="table-long" id="deliveries">
<tr>
<th>Portador</th>
<th>Cliente</th>
<th>Data de Cadastro</th>
<th>Descrição</th>
<th>Status</th>
<th>Motivo Entrega Não Realizada</th>
<th><input type="checkbox" id="selectAllCheckBoxes" /></th>
<th colspan="4">
<div class="btnSituacao" hidden>
<button onclick="enviarFormulario()">Salvar</button>
<button id="cancel">Cancelar</button>
</div>
</th>
<th></th>
@if (Model != null)
{
for (int i = 0; i < Model.DeliveryServices.Count; i++)
{
var checkboxChecked = Model.DeliveryServices[i].IsSelected;
<tr>
<td>@Html.DisplayFor(modelItem => carrierFullName)</td>
<td>@Html.DisplayFor(modelItem => shipperCustomerFullName)</td>
<td>@Html.DisplayFor(modelItem => Model.DeliveryServices[i].Created)</td>
<td>@Html.DisplayFor(modelItem => Model.DeliveryServices[i].Description)</td>
<td>@Html.DisplayFor(modelItem => Model.DeliveryServices[i].DeliveryServiceStatusModel.Description)</td>
<td>@Html.DisplayFor(modelItem => Model.DeliveryServices[i].NonDeliveryDescription)</td>
@*declaração de variavel local para simplificar o tratamento condicional de "description"*@
@{var description = Model.DeliveryServices[i].DeliveryServiceStatusModel.Description;}
@if (description == "Em Andamento" || description == "Roteirizado")
{
<td>@Html.CheckBoxFor(modelItem => Model.DeliveryServices[i].IsSelected)</td>
}
else
{
<td></td>
}
}
}
</table>
Your question is confused. A button
submit
having aJavascript
meaningless in my view, seems to be the problem.– novic
I removed the Ubmit, the button calls to
ActionResult
but I do not know how to pass my list as parameter.– Vinicius
post your
form
complete....?– novic