我有一个带有两个动作的控制器和一个带有两个图表的视图,第一个直接在视图上,第二个是部分视图,如下所示:
<div class="chart" style="margin-top: 10px;">
@(Html.Telerik().Chart(Model)
.Name("CustomerCount")
.Title(title => title.Text("TotalCustomersPerHour"))
.Legend(settings => settings.Position(ChartLegendPosition.Bottom))
.Series(series => series.Line(p => p.CustomerCount.Total).Name("TotalCustomersPerHour"))
.CategoryAxis(a => a.Categories(p => p.CustomerCount.Intervalo).Labels(l => l.Rotation(-40))).Theme("vista")
.Tooltip(true)
.HtmlAttributes(new { style = "height: 300px;" })
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("CustomerCountData", "Indicators", new
{
storeId = "TR_001",
startDate = DateTime.Today,
endDate = DateTime.Today.AddDays(10)
}))
.ClientEvents(b => b.OnDataBound("OnCustomerCountDataBound"))
)
</div>
<div class="chart" style="margin-top: 10px;">
@Html.Partial("_ChartTest")
</div>
第一个动作由 Telerik Chart Ajax 调用调用,完成后我通过 OnDataBound 事件调用另一个动作,以便使用 ViewBags 填充我的部分视图图表。
function OnCustomerCountDataBound(e) {
$.ajax({
type: "POST",
url: "Indicators/ChartTest",
data: { retailStoreId: "TR_001"},
});
}
我调试了部分视图,我可以获得 ViewBag 值,但结果未显示在页面上。
@(Html.Telerik().Chart()
.Name("TimeOfPermanency")
.Title(title => title.Text(TrackerMessages.TimeOfPermanencyPerArea))
.Legend(settings => settings.Position(ChartLegendPosition.Bottom))
.Series(series =>
{
if (ViewBag.Series != null)
{
foreach (var area in ViewBag.Series)
{
series.Column(area.Data).Name(area.Name);
}
}
})
.CategoryAxis(axis =>
{
if (ViewBag.Categories != null)
{
axis.Categories(ViewBag.Categories);
}
})
.Tooltip(true)
.HtmlAttributes(new { style = "height: 300px;" })
.ClientEvents(b => b.OnDataBound("OnTimeOfPermanency"))
)
任何人都知道为什么结果没有在我的第二张图表上呈现?
谢谢!