【问题标题】:Kendo Dropdownlist value is not getting with class selectorKendo Dropdownlist 值未与类选择器一起使用
【发布时间】:2017-05-11 12:17:31
【问题描述】:

我正在使用 Kendo UI 框架开发一个 Web 应用程序。 HTML文件如下:-

<div class="grand_parent">

    <div class="parent1"> 
        <div class="child1"></div>
    </div>

    <div class="parent2">
        <div class="child2"></div>
    </div>

</div>

'grand_parent' 类将根据条件重复。在这个 'child1' 和 'child2' 类将与 Kendo 下拉列表绑定。

$(".child1").kendoDropDownList({
    dataTextField: "text",
    dataValueField: "value",
    dataSource: options1,
    index: 0,
});

$(".child2").kendoDropDownList({
    dataTextField: "text",
    dataValueField: "value",
    dataSource: options2,
    change: onSelect,
    index: 0,
});


options1 = [
    {text:"Child1", value:1},
    {text:"Child2", value:2},
    {text:"Child3", value:3},
];

options2 = [
    {text:"newChild1", value:'5'},
    {text:"newChild2", value:'6'},
    {text:"newChild3", value:'7'},
];

function onSelect(e){
    var value = e.sender.value();
    switch (value) {
        case 5:
        case 6:
        case 7:

           // Printing a combination string of both drop downlist's selected value(Example: "5_1")

            break;

        default:

            break;
    }
}

获取下拉列表值有问题。要获取第一行“child1 dropdownlist”值(在更改第一行中的“child2 dropdownlist”时)我使用 $(this.element).closest(".parent2").siblings(".parent1").find(".child1").data("kendoDropDownList").value();

但我收到如下错误:-

Uncaught TypeError: Cannot read property 'value' of undefined

请帮忙

【问题讨论】:

    标签: kendo-dropdown


    【解决方案1】:

    将您的 DOM 导航表达式更改为:

    $(this.element).closest(".parent2").siblings(".parent1").find("div.child1").data("kendoDropDownList").value();
    

    Here 你可能会找到一个可行的例子。

    基本上问题是find(.child1) 返回 2 个 DOM 元素,您必须修复该选择器才能到达正确的组件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-14
      • 2014-03-14
      相关资源
      最近更新 更多