无法填充card_Select from meter_Select。 我每次使用set方法来设置和存储米_选择被更改。
请参阅以下代码: -
var store = new Memory({
data:[
{id:'', label:"Choose one of the cards"},
{id:'testdata1970_05', label:"Mk7ABC Card"},
{id:'testdata1970_10', label:"Mk7CBC Card"},
{id:'testdata2060_03', label:"Mk10BC Card"},
]});
var memoStore1 = new ObjectStore({objectStore:store});
var meter_Select = new Select
({store:memoStore1,
style:{width:'140px'},
}, "node_meterSelect");
meter_Select.startup();
var card_Select = new Select
({style:{position: 'absolute', margin: '20px', left:'60px', width:'140px'},
id:'cardSelect'
}, "node_cardSelect");
on(meter_Select, 'change', function(evt)
console.debug('Selected Card = '+ meter_Select.value);
request.post('listofcards.php',{data:{cardX : meter_Select.value},
handleAs:"json"}).then(
function(response)
{var memoStore2 = new Memory({data:response});//ok
console.debug("Loaded into memoStore2 ->" +memoStore2);
var combx = registry.byId('cardSelect');//ok to be undefined.
combx.set('store', memoStore2);
combx.set('value',"");
combx.set('placeHolder',"Choose one of the batch...");
combx.set('searchAttr', 'mfg_code');
combx.startup();
},//function(response)
function(error)//ok
alert('Getting a list of cards = '+error);
}//function(error)
)//then.});//meter_Select.on
有什么想法吗? 克莱门特
答案 0 :(得分:1)
在this jsfiddle中,第二个选择是从Ajax请求中填充的,该请求是从第一个选择中触发的。
它的关键在于这个函数,为select创建了一个新的ObjectStore
,调用了setStore()
方法来更新dijit:
function onDataLoaded(response) {
var memory = new Memory({
data: response
});
var store = new ObjectStore({
objectStore: memory
});
console.log("response", response, "store", store);
var cardSelect = registry.byId('cardSelect');
console.log(cardSelect);
cardSelect.setStore(store);
}