我目前有一个类似于以下代码的表单。
@using (Ajax.BeginForm("List", "Package", null, new AjaxOptions
{
HttpMethod = "GET",
UpdateTargetId = "zone-package-details",
OnFailure = "searchFail",
OnComplete = "getinfotoprint()" //seperate function to deal with printing feature
}, new { id = "form-package-search" }))
{
<div class="row">
<div class="col-3">
<h4>All Packages </h4>
</div>
<div class="row">
<div class="col ">
@Html.DropDownListFor(x => x.Fielditems, new SelectList(Listitem.Fields, "FieldID", "Name"), new { @class = "form-control", id = "field", onchange = "$(this.form).submit();" })
</div>
<div class="row" style="padding-left:20px">
@Html.EditorFor(model => model.Start, new { htmlAttributes = new {id = "start", @class = "form-control", style = "width:180px", onchange = "$(this.form).submit();"} })
@Html.EditorFor(model => model.End, new { htmlAttributes = new { id = "end", @class = "form-control", style = "width:180px", onchange = "$(this.form).submit();"} })
</div>
</div>
</div>
}
此表单按预期工作,并返回部分视图“列表”。我正在尝试向pdf打印添加图标。为此,我尝试使用Rotativa,因为这似乎是最简单的解决方案。但是,rotativa函数要求我调用一个返回视图的操作,以便将数据转换为pdf。结果,我在调用该List操作时遇到麻烦,该操作将使用rotativa返回列表视图,因为list操作要求我将上面列出的3个参数传递给它。那么,如何从视图中获取这三个参数的值?我尝试使用模型来获取这些值,但我相信除非提交表单,否则不会填充模型。那么,如何在无需提交表单的情况下获取用户输入内容的值,以便将这些值传递给rotativa函数并返回pdf?
注释:我也尝试使用ajax,此方法有效,但结果返回给ajax函数,因此未下载pdf文件。