【发布时间】:2013-11-18 19:38:40
【问题描述】:
我正在尝试根据从另一个下拉列表中选择的值 (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");
提前致谢!
【问题讨论】:
-
cboSearchString1DDL.element[0].value 在远程服务调用发生时显然为空。谢谢。
-
好吧,您发布的代码中肯定没有定义。所以定义它或发布更多你的代码。
-
很抱歉,我已经更新了我的代码,并考虑到了简洁性。
-
cboSearchString1DDL 仍未在任何地方定义。您是否将 jquery 选择器与变量名混在一起?
-
我猜你应该这样做:
$('#cboSearchString1DDL').val()而不是cboSearchString1DDL.element[0].value
标签: javascript kendo-ui kendo-combobox kendo-dropdown