我有2个jqxDropDownList,项目是equls。
我编写此代码,但此代码向服务器发送2个请求(与之相同)。
如何将项目从第一个jqxDropDownList复制到第二个jqxDropDownList?
var source = {
datatype: "json",
datafields: [{
name: 'organizationName'
}, {
name: 'id'
}],
id: 'id',
url: "getOrganizationName",
async: true
};
var dataAdapter = new $.jqx.dataAdapter(source);
//people
$("#slc_organizationName_people").jqxDropDownList({
source: dataAdapter,
displayMember: "organizationName",
valueMember: "id"
});
//address
$("#slc_organizationName_address").jqxDropDownList({
source: dataAdapter,
displayMember: "organizationName",
valueMember: "id"
});
答案 0 :(得分:1)
您可以尝试以下方法:
var source = {
datatype: "json",
datafields: [{
name: 'organizationName'
}, {
name: 'id'
}],
id: 'id',
url: "getOrganizationName",
async: true
};
var dataAdapter = new $.jqx.dataAdapter(source,{
loadComplete: function()
{
//address
var source2 = {
datatype: "array",
datafields: [{
name: 'organizationName'
}, {
name: 'id'
}],
id: 'id',
localdata: dataAdapter.records
};
var adapter = new $.jqx.dataAdapter(source2);
$("#slc_organizationName_address").jqxDropDownList({
source: adapter ,
displayMember: "organizationName",
valueMember: "id"
});
}
});
//people
$("#slc_organizationName_people").jqxDropDownList({
source: dataAdapter,
displayMember: "organizationName",
valueMember: "id"
});