Kendo网格-将行过滤为kendoDropDown [英] Kendo Grid - Filter Row as kendoDropDown

查看:114
本文介绍了Kendo网格-将行过滤为kendoDropDown的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在发布问题作为答案后在这里,我通过以下方式对此进行了更正创建新问题.

After posting question as answer here, I correct this by creating new question.

我正在尝试在Kendo网格中创建行过滤器,以在该列中显示为可能的值的DropDown.到目前为止,我得到的最接近的是Pluc在链接问题中的示例 .仍然无法按预期工作.

I'm trying to create row filter in kendo grid to appear as DropDown of possible values in that column. So far, closest I got is Pluc's example in linked question. Still it doesn't work as intended.

在kendoGrid的列中,我定义了一个像这样的字段:

In columns of kendoGrid I defined a field like this:

{ 
    field: "Herkunft", 
    title: "Herkunft", 
    width: "120px", 
    type: "string", 
    filterable: 
    { 
        cell: 
        { 
            showOperators: false, 
            template: herkunftDropDownEditor
        }
    }  
 }

这是herkunftDropDownEditor函数:

This is herkunftDropDownEditor function:

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错误即将出现:

It doesn't work. The JS error I get in Chrome is on the line:

element.kendoDropDownList({

错误说:"Uncaught TypeError: undefined is not a function".由于某种原因,它不能使用kendoDropDownList函数.

error says: "Uncaught TypeError: undefined is not a function". For some reason it can't use kendoDropDownList function.

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

What I also find confusing is the way Telerik use template in their example: template: "#=FirstName# #=LastName#" The way they do it is connecting the function to ui instead of template. I tried this approach also, calling ui: herkunftDropDownEditor instead of template: herkunftDropDownEditor. This way there is no error, but it doesn't work. The search field is still textbox. When I debug in Chrome, I see that argument element in the function is not even available.

不知道我在做什么错.

推荐答案

我在链接文章中更新了答案.

I updated my answer in the link post.

从2014年第二季度SP1开始,模板函数现在接收包含数据源"和元素"的对象.

Starting from 2014 Q2 SP1, the template function now receives an object containing "datasource" and "element".

更改

element.kendoDropDownList({

element.element.kendoDropDownList({

这篇关于Kendo网格-将行过滤为kendoDropDown的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆