【发布时间】:2014-12-14 22:50:49
【问题描述】:
在将问题作为答案here 发布后,我通过创建新问题来更正此问题。
我正在尝试在 kendo 网格中创建行过滤器,以显示为该列中可能值的 DropDown。到目前为止,我得到的最接近的是 Pluc 的示例in linked question。仍然没有按预期工作。
在 kendoGrid 的列中,我定义了一个这样的字段:
{
field: "Herkunft",
title: "Herkunft",
width: "120px",
type: "string",
filterable:
{
cell:
{
showOperators: false,
template: herkunftDropDownEditor
}
}
}
这是herkunftDropDownEditor函数:
function herkunftDropDownEditor(element) {
element.kendoDropDownList({
autoBind: false,
optionLabel: "--Select Value--",
dataTextField: "Value",
dataValueField: "Value",
valuePrimitive: true,
dataSource: herkunftDataSource
});
}
下拉列表的数据源:
var herkunftDataSource = new kendo.data.DataSource({
data: [
{ Value: "Choice One" },
{ Value: "Choice Two" }
]
});
它不起作用。我在Chrome中遇到的JS错误就行了:
element.kendoDropDownList({
错误提示:"Uncaught TypeError: undefined is not a function". 由于某种原因它不能使用 kendoDropDownList 函数。
我还感到困惑的是 Telerik 在他们的示例中使用模板的方式:template: "#=FirstName# #=LastName#" 他们这样做的方式是将函数连接到 ui 而不是 template。我也尝试了这种方法,调用ui: herkunftDropDownEditor 而不是template: herkunftDropDownEditor。这种方式没有错误,但它不起作用。搜索字段仍然是文本框。当我在 Chrome 中调试时,我看到函数中的参数 element 甚至不可用。
不知道我做错了什么。
【问题讨论】:
-
如果您发布示例的 JSBin,我可以进一步帮助您。这种错误通常意味着您只是在错误的范围/顺序中声明了事物。
标签: telerik kendo-grid telerik-grid