In Controller I have ActionResult FilterPo
Which first Lists all the records from the table and also I am adding a Select Filter for one of the fields in this Action and sending this to the VOew
From the Razor view then want this selected records to be printed as PDF using Rotativa
In my Controller i have the Action method which will again call the View and display only the selected Criteria from a Drop Down
public ActionResult FilterPo(string ponumbersFilter)
{
using (axisSignagedb dbmodel = new axisSignagedb())
{
var ponos = dbmodel.signagecomlaints
.Select(p => p.PO_number)
.Distinct()
.OrderBy(c => c)
.ToList();
ViewBag.ponumbersFilter = new SelectList(ponos);
// Filter projects if region is selected
var zoneNames = dbmodel.signagecomlaints.AsQueryable();
if (!string.IsNullOrEmpty(ponumbersFilter))
{
ViewBag.POCount = dbmodel.signagecomlaints.Where(x => x.PO_number == ponumbersFilter).Count();
return View(dbmodel.signagecomlaints.Where(x => x.PO_number == ponumbersFilter).ToList());
}
else
{
ViewBag.POCount = dbmodel.signagecomlaints.Count();
return View(dbmodel.signagecomlaints.ToList());
}
}
}
Also have the PrinttoPDF Action method
public ActionResult GeneratePdfRotativa()
{
using (axisSignagedb dbmodel = new axisSignagedb())
{
return new Rotativa.ActionAsPdf("Index")
{
FileName = "Export.pdf",
PageSize = Rotativa.Options.Size.A4,
PageOrientation = Rotativa.Options.Orientation.Portrait,
PageMargins = { Left = 10, Right = 10, Top = 10, Bottom = 10 }
};
}
}
When i print it shows all records in the Table
I want to print only the selected Records from the View as PDF using Rotative
Pls suggest