【发布时间】:2011-12-06 14:52:36
【问题描述】:
我有这样的看法:
@model IEnumerable<VectorCheck.Models.Invoice>
@{
ViewBag.Title = "Exportable Invoices";
}
<script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.16.min.js" type="text/javascript"></script>
<script src="../../Scripts/Views/Export/index.js" type="text/javascript"></script
<header class="header">
<div class="headerText">
<h1>Exportable Invoices</h1>
</div>
</header>
@using (Html.BeginForm("Export", "Export")) {
<table>
<tr class="mainheader">
<th>Invoice Number</th>
<th>Date</th>
<th>Organisation</th>
<th>Total (Excl GST)</th>
<th>Status</th>
<th>Exported Date</th>
<th>
<select id="expenseSelect"></select>
<input type="submit" id="btnexport" value="Export" />
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.InvoiceNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.InvoiceDate, "{0:D}")
</td>
<td>
@Html.DisplayFor(modelItem => item.Organisation.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.TotalExcludingGst)
</td>
<td>
@Html.DisplayFor(modelItem => item.Status)
</td>
<td>
@Html.DisplayFor(modelItem => item.ExportedDateTime)
</td>
<td class="centered">
<input type="checkbox" class="exportcheckbox" data-invoiceid=@item.InvoiceId />
</td>
</tr>
}
</table>
}
<div>
@Html.ActionLink("Back to Summary", "Index", "Invoice")
</div>
好的,看看每个复选框如何具有data-invoiceid=@item.InvoiceId 属性。好吧,我正在尝试使用一种操作方法来检查所有已检查其复选框的发票的 ID。此外,我正在尝试获取选择列表费用选择的 ID,该 ID 在通过 jquery 加载页面时添加了选项。我设法用 jquery 实现了这一点,然后用$.post 发送数据。问题出在我将信息发送到的文件中:
public ActionResult Export()
{
...
var csvData = _utility.GetCsvData(data);
return File(Encoding.UTF8.GetBytes(csvData), "text.csv", "invoices.csv");
}
打开保存/打开文件对话框。我被告知这不适用于 jquery ajax 调用,我需要使用提交将信息发回。
很好,但现在我不知道如何将选择 ID 和选中复选框的 ID 列表发送到方法。谁能告诉我该怎么做?
【问题讨论】:
标签: asp.net-mvc