我有一个如下所述的剑道网格。看起来很好,除了我不能在" Round"上使用客户端过滤器之外,所有其他列都运行良好。柱。多选过滤器看起来不错,但是当我选择一些值并按下"过滤器"按钮它会抛出一个javascript错误 - 只为这个专栏!它甚至可以正常排序。
未捕获的TypeError :( GameType.RoundNo ||"")。toLowerCase不是函数
它似乎是由架构中GameType
对象的结构引起的。我无法将数据类型设置为type:"number"
,因为我需要为此网格的编辑功能设置默认值(我在下面的示例中省略了该值)。我不知道如何同时设置默认值和数据类型,我甚至不确定这会解决我的问题。
<div id="tblGames"></div>
<script src="http://cdn.kendostatic.com/2015.1.429/js/kendo.all.min.js"></script>
<script>
$(document).ready(function () {
$("#tblGames").kendoGrid({
sortable: true,
groupable: true,
filterable: true,
columns: [
{ field: "Season", title: "Season", type: "number", filterable: { multi: true }, width: 100 },
{ field: "GameType.RoundNo", title: "Round", type: "number", filterable: { multi: true }, width: 90 },
{ field: "GameDate", title: "Date", type: "date", format: "{0:dd/MMM hh:mmtt}", width: 130 },
{ field: "Grade.GradeName", title: "Grade", filterable: { multi: true } },
{ field: "HomeTeam.TeamName", title: "Home", filterable: { multi: true } },
{ field: "AwayTeam.TeamName", title: "Away", filterable: { multi: true } },
{ title: "Score", template: "#= ScoreFor + ' - ' + ScoreAgainst #", width: 70, filterable: false },
{ field: "IsPlayed", title: "Played?", filterable: { multi: true }, width: 95 }
],
dataSource: {
schema: {
model: {
id: "GameID",
fields: {
GameID: { editable: false, defaultValue: 0 },
GameType: { defaultValue: { GameTypeID: 1, RoundNo: 0 }, validation: { required: true } },
GameDate: { type: "date", required: true },
Season: { type: "number" },
Grade: { defaultValue: { GradeID: 1 }, validation: { required: true } },
Ground: { defaultValue: { GroundID: 1 }, validation: { required: true } },
HomeTeam: { defaultValue: { TeamID: 1 }, validation: { required: true } },
AwayTeam: { defaultValue: { TeamID: 1 }, validation: { required: true } },
ScoreFor: { type: "number", validation: { min: 0, required: true } },
ScoreAgainst: { type: "number", validation: { min: 0, required: true } },
IsPlayed: { type: "boolean", defaultValue: true }
}
}
},
data: [{"GameID":1,"Grade":{"GradeID":1,"GradeName":"A Grade"},"GameType":{"GameTypeID":1,"Description":"Regular Season","RoundNo":1,"Round":"Round 1"},"Season":2015,"GameDate":"\/Date(1432702800000)\/","Ground":{"GroundID":1,"GroundName":"Main Oval, Mainland"},"HomeTeam":{"TeamID":1,"TeamName":"A Team"},"AwayTeam":{"TeamID":2,"TeamName":"Losers R Us"},"ScoreFor":10,"ScoreAgainst":0,"IsPlayed":true,"ErrorMessage":null},
{"GameID":2,"Grade":{"GradeID":2,"GradeName":"B Grade"},"GameType":{"GameTypeID":1,"Description":"Regular Season","RoundNo":2,"Round":"Round 2"},"Season":2015,"GameDate":"\/Date(1432659159000)\/","Ground":{"GroundID":2,"GroundName":"Happy Park, Happyland"},"HomeTeam":{"TeamID":3,"TeamName":"B Team"},"AwayTeam":{"TeamID":2,"TeamName":"Losers R Us"},"ScoreFor":55,"ScoreAgainst":0,"IsPlayed":true,"ErrorMessage":null}]}
});
});
</script>
我也没有成功尝试过:
GameType: [{ RoundNo: { type: "number", defaultvalue: 0, validation: { required: true } } }, { GameTypeID: { defaultValue: 1, validation: { required: true } } }],
答案 0 :(得分:1)
如果在数据集中将RoundNo值设置为字符串,则过滤工作正常。
$(document).ready(function () {
$("#tblGames").kendoGrid({
sortable: true,
groupable: true,
filterable: true,
columns: [
{ field: "Season", title: "Season", type: "number", filterable: { multi: true }, width: 100 },
{ field: "GameType.RoundNo", title: "Round", type: "number", filterable: { multi: true }, width: 90 },
{ field: "GameDate", title: "Date", type: "date", format: "{0:dd/MMM hh:mmtt}", width: 130 },
{ field: "Grade.GradeName", title: "Grade", filterable: { multi: true } },
{ field: "HomeTeam.TeamName", title: "Home", filterable: { multi: true } },
{ field: "AwayTeam.TeamName", title: "Away", filterable: { multi: true } },
{ title: "Score", template: "#= ScoreFor + ' - ' + ScoreAgainst #", width: 70, filterable: false },
{ field: "IsPlayed", title: "Played?", filterable: { multi: true }, width: 95 }
],
dataSource: {
schema: {
model: {
id: "GameID",
fields: {
GameID: { editable: false, defaultValue: 0 },
GameType: { defaultValue: { GameTypeID: 1, RoundNo: 0 }, validation: { required: true } },
//GameType: [{ RoundNo: { type: "number", defaultvalue: 0, validation: { required: true } } }, { GameTypeID: { defaultValue: 1, validation: { required: true } } }],
GameDate: { type: "date", required: true },
Season: { type: "number" },
Grade: { defaultValue: { GradeID: 1 }, validation: { required: true } },
Ground: { defaultValue: { GroundID: 1 }, validation: { required: true } },
HomeTeam: { defaultValue: { TeamID: 1 }, validation: { required: true } },
AwayTeam: { defaultValue: { TeamID: 1 }, validation: { required: true } },
ScoreFor: { type: "number", validation: { min: 0, required: true } },
ScoreAgainst: { type: "number", validation: { min: 0, required: true } },
IsPlayed: { type: "boolean", defaultValue: true }
}
}
},
data: [{"GameID":1,"Grade":{"GradeID":1,"GradeName":"A Grade"},"GameType":{"GameTypeID":1,"Description":"Regular Season","RoundNo":"1","Round":"Round 1"},"Season":2015,"GameDate":"\/Date(1432702800000)\/","Ground":{"GroundID":1,"GroundName":"Main Oval, Mainland"},"HomeTeam":{"TeamID":1,"TeamName":"A Team"},"AwayTeam":{"TeamID":2,"TeamName":"Losers R Us"},"ScoreFor":10,"ScoreAgainst":0,"IsPlayed":true,"ErrorMessage":null},
{"GameID":2,"Grade":{"GradeID":2,"GradeName":"B Grade"},"GameType":{"GameTypeID":1,"Description":"Regular Season","RoundNo":"2","Round":"Round 2"},"Season":2015,"GameDate":"\/Date(1432659159000)\/","Ground":{"GroundID":2,"GroundName":"Happy Park, Happyland"},"HomeTeam":{"TeamID":3,"TeamName":"B Team"},"AwayTeam":{"TeamID":2,"TeamName":"Losers R Us"},"ScoreFor":55,"ScoreAgainst":0,"IsPlayed":true,"ErrorMessage":null}]}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<head>
<base href="http://demos.telerik.com/kendo-ui/grid/index">
<style>
html {
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
}
</style>
<title></title>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.material.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.dataviz.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.429/styles/kendo.dataviz.material.min.css" />
<script src="http://cdn.kendostatic.com/2015.1.429/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2015.1.429/js/kendo.all.min.js"></script>
</head>
<body>
<div id="example">
<div id="tblGames"></div>
</div>
</body>
</html>