繁体   English   中英

选择级联下拉列表的默认值

[英]Selecting the Default value of Cascading Dropdown list

我只想问问如何在第一个下拉列表更改时选择第二个/级联下拉列表的默认值? 更改位置下拉列表后,我想选择[Please Select Location] ,但是我尝试了此方法,但错误提示select is undefined

  var dropdownlist = $("#ddlLocation").data("kendoDropDownList");
                dropdownlist.select(function (dataItem) {
                    return dataItem.symbol === "[Please Select Location]";
                });

这是我的一组代码:

var userId = $("#hiddenUser").val();
    $("#PositionInputs").kendoDropDownList({
        dataTextField: "Name",
        dataValueField: "ID",
        index: 0,
        autoBind: false,
        change: function () {
            var value = this.value();
            var dataItem1 = this.dataItem(this.select());
            if (value) {
                var dropdownlist = $("#ddlLocation").data("kendoDropDownList");
                dropdownlist.select(function (dataItem) {
                    return dataItem.symbol === "[Please Select Location]";
                });

            }
        },
        optionLabel: "[Please Select Position]",
        template: '<h5>${ data.Name }</h5>',
        dataSource: {
            transport: {
                read: {
                    url: '/Profile/LoadDropdownList?userId=' + userId,
                    dataType: "json",
                    type: "POST"

                }
            }
        }

    });


    //kendo dropdown
    $("#ddlPosition").kendoDropDownList({
        dataTextField: "Name",
        dataValueField: "ID",
        autoBind: false,
          optionLabel: {
              Name: "[Please Select Position]",
              ID: "0"
    },
        //   define custom template
        template:
                                   '<h5>${ data.Name }</h5>',
        dataSource: {
            transport: {
                read: {
                    url: '/Profile/LoadDropdownList?userId=' + userId,
                    dataType: "json",
                    type: "POST"
                }
            }
        }
    });



    //kendo dropdown
    $("#ddlLocation").kendoDropDownList({
        dataTextField: "Address",
        dataValueField: "Id",
        autoBind: false,
        optionLabel: "[Please Select Position]",
        //   define custom template
        template: '<h5>${ data.Address }</h5>',
        dataSource: {
            transport: {
                read: {
                    url: '/Profile/LoadLocationDropdownList?userId=' + userId,
                    dataType: "json",
                    type: "POST"
                }
            }
        }

    });




    $("#LocationInputs").kendoDropDownList({
        dataTextField: "Address",
        dataValueField: "Id",
        //                    index: 0,
        autoBind: false,
        cascadeFrom: "PositionInputs",
        optionLabel: {
            Address: "[Please Select Position]",
            Id: "0"
        },
        template: '<h5>${ data.Address }</h5>',
        dataSource: {
            transport: {
                read: {
                    url: '/Profile/LoadLocationDropdownList?userId=' + userId,
                    dataType: "json",
                    type: "POST"
                }
            }
        }
    });

如果文本等于“ [请选择位置]”,但您使用的代码会选择该项目,但此处定义的位置下拉菜单设置为“ [请选择位置]”。

如果无法进行该更改,则可以尝试设置索引(假设占位符的索引为0):

var ddl = $("#someId").data("kendoDropDownList");
ddl.select(0)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM