Kendo ui 剑道饼图MVC数据绑定
我对Telerik在MVC中的剑道UI饼图有意见。我在他们的网站上找不到任何像样的代码示例。我发现的一个演示只显示了一半的代码,所以我试着猜测如何让它工作。我遇到了一个错误,无论我如何努力消除这个错误,似乎都没有任何效果。实际上绑定数据的series.Pie部分有问题。我复制了他们示例中的代码,并像他们一样使用lambda表达式。model=>model.Percentage和model=>model.StatusName以使用我的视图模型。但它在第一个lambda上出错,并显示以下错误消息: CS1660:无法将lambda表达式转换为类型“string”,因为它不是委托类型 以下是相关代码: 视图模型/视图:Kendo ui 剑道饼图MVC数据绑定,kendo-ui,kendo-asp.net-mvc,kendo-dataviz,kendo-chart,Kendo Ui,Kendo Asp.net Mvc,Kendo Dataviz,Kendo Chart,我对Telerik在MVC中的剑道UI饼图有意见。我在他们的网站上找不到任何像样的代码示例。我发现的一个演示只显示了一半的代码,所以我试着猜测如何让它工作。我遇到了一个错误,无论我如何努力消除这个错误,似乎都没有任何效果。实际上绑定数据的series.Pie部分有问题。我复制了他们示例中的代码,并像他们一样使用lambda表达式。model=>model.Percentage和model=>model.StatusName以使用我的视图模型。但它在第一个lambda上出错,并显示以下错误消息:
public class StatusPercentageViewModel
{
public string StatusName { get; set; }
public int Count { get; set; }
public double Percentage { get; set; }
}
@model IEnumerable<StatusPercentageViewModel>
@(Html.Kendo().Chart(Model)
.Name("StatusBreakdown")
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.Series(series =>
{
series.Pie(
model => model.Percentage,
model => model.StatusName,
null,
null
);
})
.Tooltip(tooltip => tooltip.
Template("${ category } - ${ value }%").Visible(true)
)
)
如果要这样定义系列,可能需要指定模型。看 例如:
@(Html.Kendo().Chart<StatusPercentageViewModel>()
.Name("StatusBreakdown")
.Legend(legend => legend.Position(ChartLegendPosition.Bottom))
.DataSource(ds => ds.Read(read => read.Action("GetStatus", "Status")))
.Series(series =>
{
series.Pie(
model => model.Percentage,
model => model.StatusName
);
})
.Tooltip(tooltip => tooltip.Template("${ category } - ${ value }%").Visible(true))
)
另一种更类似于您现在要做的事情的方法是:
@model IEnumerable<StatusPercentageViewModel>
@(Html.Kendo().Chart()
.Name("StatusBreakdown")
.Legend(legend => legend.Position(ChartLegendPosition.Bottom))
.Series(series => series.Pie(Model))
.Tooltip(tooltip => tooltip.Template("${ category } - ${ value }%").Visible(true))
)
这个问题呢???