0

我有 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"
     });
4

1 回答 1

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"
 });
于 2015-04-20T07:26:14.467 回答