2014-02-10 52 views
1

從@MichaelSaiz獲得此代碼並略微改變它,並且日曆小部件與Domino服務器上的dojo 1.5.x附帶的Calendar.css看起來/效果很好。從dojo小部件刷新視圖面板

但是,當用戶點擊日期時,我需要刷新日曆視圖,雖然字段正在刷新確定,視圖行爲奇怪,我不明白爲什麼?

XSP.addOnLoad(函數(){

dojo.require("dojox.widget.Calendar"); 
    dojo.require("dojo.date","dijit.registry"); 
    dojo.require("dojo.date.locale"); 
    dojo.require("dijit.Calendar"); 
    dojo.ready(function(){  
     // create the Calendar: 
     var selectedDate = null; 

     var calendar_body = new dojox.widget.Calendar({ 
       value: new Date(), 

       onValueSelected: function(date){calendarDateClicked(date); 
       } 
      }, "calendar_body"); 


     //create Click action 
     function calendarDateClicked(date){ 
      var d = new Date(date); 

      var month = '' + (d.getMonth() + 1); 
      var day = '' + d.getDate(); 
      var year = d.getFullYear(); 
      if (month.length < 2) month = '0' + month; 
      if (day.length < 2) day = '0' + day; 


      var dateString = [day,month,year].join("/"); 

      var y = dojo.date.locale.format(d, {datePattern:"dd/MM/yyyy", selector: 'date'}); 


      //dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = dateString 
      dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = y; 

      dojo.byId('#{id:calDate}').value = y; 
      //dojo.byId('#{id:calDate}').value = dateString; 
      XSP.partialRefreshGet("#{id:dayPanel1}",{});//Post Value to server 
     } 
    }); 
}); 

此火災時,用戶點擊日曆和它更新的字段(calDate),然後更新viewPanel中(dayPanel1)。

視圖在此基礎上點擊日曆集的calDate場被過濾。

任何想法如何,我可以得到,當用戶點擊日曆視圖刷新?似乎簡單,但它的駕駛我堅果!

格雷姆

+0

看來這個觀點並沒有找到適合您的過濾器entrys。莫比雙檢篩選值。 –

+0

@MichaelSaiz嗨,我應該說,我的一個測試是在視圖上方添加日期/時間字段,然後使用該日期而不是日曆更改日期。它使用該方法工作正常 - 仍然設置sessionScope變量,然後對viewPanel進行局部刷新。 – NotesNut

+0

更新了代碼...任何想法? – NotesNut

回答

1

日期格式不正確(如@MichaelSaiz推測)。現在排序了。

XSP.addOnLoad(函數(){

dojo.require("dojox.widget.Calendar"); 
    dojo.require("dojo.date","dijit.registry"); 
    dojo.require("dojo.date.locale"); 
    dojo.require("dijit.Calendar"); 
    dojo.ready(function(){  
     // create the Calendar: 
     var selectedDate = null; 

     var calendar_body = new dojox.widget.Calendar({ 
       value: new Date(), 

       onValueSelected: function(date){calendarDateClicked(date); 
       } 
      }, "calendar_body"); 



     //Set month in correct format 
     function setMonth(month){ 
      switch(month) 
      { 
      case 1: 
      month = "Jan"; 
      break; 
      case 2: 
      month = "Feb"; 
      break; 
      } 
      return month; 
     } 
     //create Click action 
     function calendarDateClicked(date){ 
      var d = new Date(date); 

      var month = (d.getMonth() + 1); 
      month = setMonth(month); 
      var day = '' + d.getDate() + ","; 
      var year = d.getFullYear(); 
      //if (month.length < 2) month = '0' + month; 
      if (day.length < 2) day = '0' + day; 


      var dateString = [month,day,year].join(" "); 

      //var y = dojo.date.locale.format(d, {datePattern:"dd/MM/yyyy", selector: 'date'}); 


      dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = dateString 
      //dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = y; 

      //dojo.byId('#{id:calDate}').value = y; 
      dojo.byId('#{id:calDate}').value = dateString; 
      XSP.partialRefreshPost("#{id:mainPanel}",{});//Post Value to server 
     } 
    }); 
});