我正在尝试根据从另一个下拉列表中选择的值(cboSearchString1DDL.element[0].value)设置远程数据 url。我继续学习剑道网络控制,所以我不确定如何最有效地完成这项任务。我尝试了几种方法,但在读取数据源时仍然出现错误。我正在尝试将其设置为关闭 DDL1。这就是我所在的位置,我知道这不是正确的方法:
// search string 1 DDL
var cboSearchString1DDL = $("#cboSearchString1DDL").kendoDropDownList({
autoBind: false,
optionLabel: " "
}).data("kendoDropDownList");
// search string 2 DDL
var cboSearchString2DDL = $("#cboSearchString2DDL").kendoDropDownList({
autoBind: false,
optionLabel: " "
}).data("kendoDropDownList");
// 1st DDL dataSource
var dataSourceTowns = new kendo.data.DataSource({
transport: {
read: {
url: _urlTowns,
dataType: "json",
}
},
schema: {
data: "Towns"
}
});
$("#cboSearchString1DDL").data("kendoDropDownList").wrapper.show();
// 1st DDL
var townsDDL = $("#cboSearchString1DDL").kendoDropDownList({
autoBind: false,
dataTextField: "Column1",
dataValueField: "Column1",
dataSource: dataSourceTowns,
close: function () {
alert(cboSearchString1DDL.element[0].value);
streetsDDL.enable(true);
streetsDDL.setDataSource(dataSourcestreetsDDL);
streetsDDL.refresh();
}
}).data("kendoDropDownList");
// show 2nd DDL
$("#cboSearchString2DDL").data("kendoDropDownList").wrapper.show();
cboSearchString2DDL.enable(false);
// 2nd DDL datasource
var dataSourcestreetsDDL = new kendo.data.DataSource({
transport: {
read: {
url: _urlSOESearchAddress + "townName=" + cboSearchString1DDL.element[0].value + "&f=",
dataType: "json",
},
},
schema: {
data: "StreetsinTown"
}
});
// 2nd DDL
var streetsDDL = $("#cboSearchString2DDL").kendoDropDownList({
autoBind: false,
dataTextField: "Street",
dataValueField: "Street",
requestStart: function (e) {
console.log("request started");
},
requestEnd: function (e) {
var response = e.response;
var type = e.type;
console.log(type);
console.log(response.length);
}
}).data("kendoDropDownList");
提前致谢!