我有以下代码:
public class AlphaNumericReportTesting
{
public string Name { get; set; }
public char Sex { get; set; }
public double Ca { get; set; }
}
部分视图,sampleView.cshtml
@model OnlineReporting.Models.AlphaNumericReportTesting;
<div id="grid"> </div>
<script>
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
data: @Html.Raw(Json.Encode(Model)),
schema: {
model: {
fields: {
Name: { type: "string" },
Sex: { type: "char" },
Ca: { type: "double" }
}
}
},
pageSize: 20
},
height: 550,
scrollable: true,
sortable: true,
filterable: true,
pageable: {
input: true,
numeric: false
},
columns: [
"Name",
{ field: "Sex", title: "Sex", width: "130px" },
{ field: "Ca", title: " Ca", width: "130px" }
]
});
});
但是当我运行代码时,我收到一个错误:&#34;检索选定报告时出错。&#34;
如何通过上面的设置显示我的数据?
请帮忙。
由于
答案 0 :(得分:2)
在Kendo中没有Char,double类型使它们全部为字符串,kendo的类型为“string,boolean,number”
@model OnlineReporting.Models.AlphaNumericReportTesting;
<div id="grid"> </div>
<script>
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
data: @Html.Raw(Json.Encode(Model)),
schema: {
model: {
fields: {
Name: { type: "string" },
Sex: { type: "string" },
Ca: { type: "string" }
}
}
},
pageSize: 20
},
height: 550,
scrollable: true,
sortable: true,
filterable: true,
pageable: {
input: true,
numeric: false
},
columns: [
{ field: "Sex", title: "Sex", width: "130px" },
{ field: "Ca", title: " Ca", width: "130px" }
]
});
});
此外,“检索所选报告时出错”与Kendo无关,请检查您的MVC操作是否存在任何服务器错误
答案 1 :(得分:0)
这&#34;检索所选报告的错误&#34;并不是来自Kendo UI。我怀疑你的网页还有其他问题。可能是服务器端异常。