带有日历弹出窗口的输入字段中的Spotfire当前日期

参考http://spotfired.blogspot.in/2014/05/popup-calendar-webplayer-compatible.html 。 在Webplayer中打开分析后,您能否建议如何在输入字段中获取当前日期。

HTML Code:    JS: //update document property after selection function datePicker_onSelect(selectedDate){ //alert(selectedDate) $("#dt1 input").focus() $("#dt1 input").blur() } //jquery datepicker configuration //you can comment the buttonImageOnly and buttonImage lines to show a button instead of a calendar or the image of your choice. pickerOptions = { showOn: 'button', buttonImageOnly: true, buttonImage: 'http://sofzh.miximages.com/javascript/cal-grey.gif', minDate: "-36M", maxDate: "+0D", changeMonth: true, changeYear: true, altField:"#dt1 input", onSelect:datePicker_onSelect } //create the date picker document.getElementById('dt1picker').innerHTML="" $("#datePicker").datepicker(pickerOptions); //--My code to get current date as soon as the analysis is load. var now = new Date(); var day = ("0" + now.getDate()).slice(-2); var month = ("0" + (now.getMonth() + 1)).slice(-2); var today = now.getFullYear() + "-" + (month) + "-" + (day); $('#dt1').val(today); 

我用JScript和Button(我隐藏所以没有人可以看到或点击它)这样做。

JScript的:

 $(function () { function executeScript() { $('#hiddenBtn input').click(); //or- document.getElementById('hiddenBtn').childNodes[0].click(); } $(document).ready(function(){executeScript()}); }); 

HTML:

  

HiddenButton上的IronPython脚本:

 from System import DateTime from Spotfire.Dxp.Data.DataType import Date if Document.Properties["OpenedYet"] == False: Document.Properties["udSelectedDate"] = DateTime.Today.ToString("MM/dd/yyyy") Document.Properties["OpenedYet"] = True 

请注意,这种方法对于开发人员来说可能有点烦人,因为每次要保存分析时,都需要进入文档属性并将OpenedYet的Property值(我作为布尔值)从True切换为False然后在点击“保存”按钮之前不能单击任何其他内容。

将此代码添加到您的查询中

 //create the date picker document.getElementById('dt1picker').innerHTML="" $("#datePicker").datepicker(pickerOptions); **$("#datePicker").datepicker("setDate", "0d");**