2016-05-12 49 views
0

我在Extjs窗口中有一個日期選擇器。例如,最短日期和默認 日期應該來自商店DateSTORE。我如何 這樣做?這是我的代碼。動態設置Extjs Datepicker的默認值和MinDate值

 { 
                xtype:'datefield', 
                margin: '20 20 0 10', 
                labelAlign: 'right', 
                labelWidth: 140, 
                width: 350, 
                itemId:'beginningDate', 
                fieldLabel: "Beginning Date", 
                minDate:function(){ 

                waitForStoreLoading([Ext.StoreManager.lookup('DateSTORE').load()], function() { 
                 debugger 

                 var dateStore = Ext.StoreManager.lookup('DateSTORE').data.items[0].data.ProductionMonth; 
                 return jsDate = new Date(parseInt(dateStore.substr(6))); 
                 var monthProduction = DateSTORE.data.items[0].data.ProductionMonthString 
                 Ext.apply(Ext.getCmp('Window').down('#beginningDate'), {minDate:jsDate}); 
                 Ext.getCmp('Window').down('#beginningDate').getView.refresh(); 
                }); 
                }(), 

但該店是不確定的。嘗試設置日期點擊按鈕,打開這個特定的'窗口'。但它也沒有發生。有任何想法嗎?

回答

0

嘗試在商店的加載事件設置最小值

//的DateField

{ 
    xtype:'datefield', 
    margin: '20 20 0 10', 
    labelAlign: 'right', 
    labelWidth: 140, 
    width: 350, 
    itemId:'beginningDate', 
    fieldLabel: "Beginning Date", 
    id:"beginningDate" 
} 

//店

{ 
    listeners:{ 
     load:funciton(store, records){ 
      var str = records[0].get("ProductionMonth"); 
      var datefield = Ext.getCmp("beginningDate"); 
      datefield.setMinValue(str); 
    }  
} 
+0

這工作完美。謝謝。不知道關於setMinValue屬性.. – bharath