Mar*_*vic 2 telerik telerik-grid kendo-grid
在这里将问题作为答案发布后,我通过创建新问题来纠正此问题.
我正在尝试在kendo网格中创建行过滤器,以显示该列中可能值的DropDown.到目前为止,我得到的最接近的是Pluc 在链接问题中的例子.它仍然没有按预期工作.
在kendoGrid的列中,我定义了一个这样的字段:
{
field: "Herkunft",
title: "Herkunft",
width: "120px",
type: "string",
filterable:
{
cell:
{
showOperators: false,
template: herkunftDropDownEditor
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是herkunftDropDownEditor函数:
function herkunftDropDownEditor(element) {
element.kendoDropDownList({
autoBind: false,
optionLabel: "--Select Value--",
dataTextField: "Value",
dataValueField: "Value",
valuePrimitive: true,
dataSource: herkunftDataSource
});
}
Run Code Online (Sandbox Code Playgroud)
和下拉列表的数据源:
var herkunftDataSource = new kendo.data.DataSource({
data: [
{ Value: "Choice One" },
{ Value: "Choice Two" }
]
});
Run Code Online (Sandbox Code Playgroud)
它不起作用.我在Chrome中遇到的JS错误就行了:
element.kendoDropDownList({
Run Code Online (Sandbox Code Playgroud)
错误说:"Uncaught TypeError: undefined is not a function".由于某种原因它不能使用kendoDropDownList函数.
我也觉得令人困惑的是Telerik在他们的例子中使用模板template: "#=FirstName# #=LastName#"的方式:他们这样做的方式是将函数连接到ui而不是template.我也试过这种方法,ui: herkunftDropDownEditor而不是template: herkunftDropDownEditor.这种方式没有错误,但它不起作用.搜索字段仍然是文本框.当我在Chrome中调试时,我发现函数element中的参数甚至不可用.
不知道我做错了什么.
我在链接帖子中更新了我的答案.
从2014 Q2 SP1开始,模板函数现在接收包含"datasource"和"element"的对象.
更改
element.kendoDropDownList({
Run Code Online (Sandbox Code Playgroud)
至
element.element.kendoDropDownList({
Run Code Online (Sandbox Code Playgroud)