gpt4 book ai didi

telerik - Kendo Grid - 将行过滤为kendo DropDown

转载 作者:行者123 更新时间:2023-12-01 22:25:33 24 4
gpt4 key购买 nike

将问题发布为答案后here ,我通过创建新问题来纠正这个问题。

我正在尝试在剑道网格中创建行过滤器,以显示为该列中可能值的下拉列表。到目前为止,我得到的最接近的是 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({

错误提示:“未捕获的类型错误:未定义不是函数”。由于某种原因,它无法使用 kendoDropDownList 函数。

我还发现 Telerik 在示例中使用模板的方式令人困惑: template: "#=FirstName# #=LastName#" 他们这样做的方式是将函数连接到 ui 而不是 template。我也尝试了这种方法,调用ui:herkunftDropDownEditor而不是template:herkunftDropDownEditor。这样虽然没有报错,但是不行。搜索字段仍然是文本框。当我在 Chrome 中调试时,我发现函数中的参数 element 甚至不可用。

不知道我做错了什么。

最佳答案

我在链接帖子中更新了我的答案。

从 2014 年 Q2 SP1 开始,模板函数现在接收包含“数据源”和“元素”的对象。

改变

element.kendoDropDownList({

element.element.kendoDropDownList({

关于telerik - Kendo Grid - 将行过滤为kendo DropDown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26457459/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com