在事件更改另一个下拉列表后刷新Kendo下拉列表

时间:2017-06-04 01:28:26

标签: c# jquery model-view-controller drop-down-menu kendo-ui

当我从第一个ddl更改值时,我从另一个ddl的Ajax获取数据,但它没有刷新。

这是我的网格

$("#grid").kendoGrid({
        dataSource: 
height: 500,
                toolbar: ["create"],
                columns: [
                     { command: ["edit"], title: " ", width: "150px", locked: true },
                    { field: "RowLabels", title: "Row Labels", width: "180px", locked: true },
                    { field: "IdValueStream", title: "VS", width: "90px", locked: true, editor: vsDropDownEditor, template: "#=getVsName(IdValueStream)#" }, //, template: "#=IdValueStream.ValueStream#"
                    { field: "IdLine", title: "Line", width: "180px", locked: true, editor: linesDropDownEditor }, //, template: "#=getLineName(IdLine)#" 
                       { field: "W1", title: Weeks[0].W1.substring(0, 10), width: "98px" }, // 
                       { field: "W2", title: Weeks[0].W2.substring(0, 10), width: "90px" },
                       { field: "W3", title: Weeks[0].W3.substring(0, 10), width: "90px" },
                       { field: "W4", title: Weeks[0].W4.substring(0, 10), width: "90px" },
                       { field: "W5", title: Weeks[0].W5.substring(0, 10), width: "90px" },
                       { field: "W6", title: Weeks[0].W6.substring(0, 10), width: "90px" },
                       { field: "W7", title: Weeks[0].W7.substring(0, 10), width: "90px" },
                       { field: "W8", title: Weeks[0].W8.substring(0, 10), width: "90px" },
                       { field: "W9", title: Weeks[0].W9.substring(0, 10), width: "90px" },
                       { field: "W10", title: Weeks[0].W10.substring(0, 10), width: "90px" },
                       { field: "W11", title: Weeks[0].W11.substring(0, 10), width: "90px" },
                       { field: "W12", title: Weeks[0].W12.substring(0, 10), width: "90px" },
                       { field: "W13", title: Weeks[0].W13.substring(0, 10), width: "90px" }
                ],
                editable: "inline"
            });

这是第一个ddl

的编辑器中的方法
function vsDropDownEditor(container, options) {
    $('<input id="ddlVs" data-bind="value:' + options.field + '"/>')
                .appendTo(container)
                .kendoDropDownList({
                    dataTextField: "ValueStream",
                    dataValueField: "Id",
                    dataSource: categories,
                    select: onSelect
                });
}

这是第二个ddl编辑器的另一个方法

function linesDropDownEditor(container, options) {

    $('<input data-bind="value:' + options.field + '"/>')
                .appendTo(container)
                .kendoDropDownList({
                    autoBind: false,
                    dataTextField: "Line",
                    dataValueField: "Id",
                    dataSource: lines
                });
}

所以当我选择第一个ddl的项目时,我想刷新第二个ddl

2 个答案:

答案 0 :(得分:0)

为第二个下拉列表添加id属性,然后在onSelect ddVs函数中添加此行代码。

$("#nameOfYourSecondDropdownHere").data('kendoDropDownList').dataSource.read();

答案 1 :(得分:0)

您还可以查看以下示例 - 在Grid中用作编辑器的Cascading DropDownLists:

Add Cascading DropDownList Editors