5
我有一個顯示項目數量的組合框。基於商品數量選擇,我正在顯示商品的價格值。默認情況下,我將價格值設置爲第一項值。然而,當我加載頁面,我想我的組合框顯示第一項數量,即100在extjs中從下拉列表(組合框)中預先選擇值?
問題:它應該載入數量:100,而裝載空白,所以我有一個存儲中定義
作爲
Store = new Ext.data.JsonStore({
storeId: 'Store',
root: 'storevalue',
autoLoad: false,
baseParams: { itemid: '${itemID!""}',
adjustPrice: '${adjustPrice}',
overrideShowPrice: '${overrideShowPrice}' },
url: 'ListQtyPrice.epm',
fields: [ 'qty', 'rawprice', 'displayPrice' ]
});
組合框以顯示數量
<#if Select>
new DBEComboBox({
name: 'orderqty',
displayField: 'qty',
valueField: 'qty',
id: 'order-qty',
store: Store,
forceSelection: true,
mode: 'remote',
triggerAction: 'all',
allowBlank: true,
listWidth: 202,
triggerClass: 'orderqty-trigger',
width: 200
,defaultValue: 100
,listeners: {
// for price adjustments
}
});
</#if>
Store.load({
callback: function() {
alert("reached");
Ext.getCmp('order-qty').setValue(Store.getAt(0).get('qty'));
var oqc = Ext.getCmp('order-qty');
var value = Ext.getCmp('order-qty').getValue();
alert(" hey :" +value);
}
});
能夠看到嘿:100在警報聲明
我要發佈沿着相同的路線(+1)的解決方案。 Mad-D,您必須確保Geronimo的代碼片段在進行任何加載調用之前。如果它仍然沒有工作,螢火蟲的任何錯誤?你能否確認商店一旦加載,確實有記錄? – 2012-01-16 22:49:49
這對我來說一直很好...這是ExtJS ** 4 **嗎?您的商店和組合框的配置與上述相同嗎?你把上面的例子放在Ext.onReady的所有其他函數之外嗎?如果你想讓它變得簡單(但不是動態的),你總是可以在組合框中添加一個'value'配置,例如:'value:'100'或'value:100' – Geronimo 2012-01-16 23:03:49
我試過這些東西1 ''store.getAt('0')。get('qty'))'在alert中獲得了預期值,即100,但它沒有設置defaultvalue。 2.當我嘗試的值:'100'和值:100它不顯示默認值爲100. – 2012-01-16 23:51:04