我有控制器:
public ActionResult Index(string Activites)
{
var item2 = (from o in frh.Dates orderby o.Date1 select o.Date1).ToArray();
int lenght = item2.Count();
string[] data = new string[lenght];
DateTime[] data3 = new DateTime[lenght];
object[] data2 = new object[lenght];
double?[] last = new double?[lenght];
// liste des mois -- string
for (int i = 0; i < lenght; i++)
{
data[i] = item2[i].ToString("dd/MM/yyyy");
//if (data[i].Equals(Dates))
//{ break; }
//if (data[i] == Dates) break;
}
//list des mois -- datetime
for ( var l = 0; l < lenght; l++)
{
data3[l] = item2[l];
// if (data3[l].Equals(Dates)) break;
// if (data3[k].ToString("dd/MM/yyyy") == Dates) break;
}
//calcul de productivité
// changement ???
var items = (from x in frh.productivites
where x.Activité == Activites
select new { x.delta_, x.tempstot_, x.DateID });
var j = 0;
foreach (var a in data3)
{
var sumd = items.Where(c => c.DateID == a).Select(c => c.delta_).Sum();
var sumt = items.Where(c => c.DateID == a).Select(c => c.tempstot_).Sum();
var prod = sumd / sumt;
last[j] = prod;
j++;
sumd = 0;
sumt = 0;
prod = 0;
}
data2 = last.Cast<object>().ToArray();
DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
.SetXAxis(new XAxis
{
Categories = data
})
.SetYAxis(new YAxis
{
Title = new YAxisTitle { Text = "Productivité " },
PlotLines = new[]
{
new YAxisPlotLines
{
Value = 0,
Width = 1,
Color = ColorTranslator.FromHtml("#808080")
}
}
})
.SetTitle(new Title
{
Text = Activites,
X = -20
})
.SetSubtitle(new Subtitle
{
Text = "Décembre 2012 - Juin 2013",
X = -20
})
.SetSeries(new Series
{
Name = "ODR",
Data = new Data(data2)
});
return PartialView(chart);
}
和部分视图:
@model DotNet.Highcharts.Highcharts
@(Model)
@section Scripts {
@Scripts.Render("~/bundles/HighChart")
}
并查看:
@{
ViewBag.Title = "Index";
}
<html>
<body>
@using (Html.BeginForm("Index", "Graphe"))
{
<table style="width: 100%;" border="1">
<tbody>
<tr aria-atomic="False" class="alt">
<td>date début :</td>
<td><input value="01/12/2012" type="text" disabled/></td>
<td style="width: 20%; position:absolute ">  </td>
</tr>
<tr>
<td>date fin :</td>
<td><select id="Dates" name="Dates" ><option>Selectionnez --</option></select></td>
<td><input id="date" type="checkbox" /> </td>
</tr>
<tr class="alt">
<td>Activité : </td>
<td><select id="Activites" name="Activites" ><option>Selectionnez --</option></select></td>
<td><input id="activite" type="checkbox" /> </td>
</tr>
<tr>
<td>Responsable:</td>
<td><select id="Responsables" name="Responsables">
<option>Selectionnez --</option></select></td>
<td><input id="Responsable" type="checkbox" /> </td>
</tr>
<tr style="height : 30%">
<td style="width: 20%">  </td>
</tr>
<tr>
<td style="width: 20%; position:absolute "></td>
<td><input type="submit" value="Afficher" id="ButtonSubmit"/></td>
<td><input class="button" id="ButtonReset" type="button" value="Annuler" /></td>
</tr>
</tbody>
</table>
}
</body>
</html>
我想要的是在按钮单击时显示部分视图;我还需要将参数(选定的值)从视图传递到控制器,以过滤在局部视图中呈现的集合,我该怎么做?