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

Spotfire Current Date in input field with calendar popup

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

HTML Code:
<span id="dt1">
<SpotfireControl id="a8b5b0d725bd41f385c3a859b511ae0b" /></span>
<span id="dt1picker"></span>  

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://staff.washington.edu/tabrooks/343INFO/UnobtrusiveDatePicker/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="<input type='hidden' id='datePicker'>"
$("#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 和一个按钮(我把它隐藏起来,这样没人能看到或点击它)来做到这一点。

JScript:

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

HTML:

<Span style="display:none" id="hiddenBtn">
<SpotfireControl id="f8322a6109af43fb935ad6e7bcb1f1fc" /></span>

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 的 属性 值(我有一个布尔值)从 True 到 False 然后在你点击保存按钮之前你不能点击任何其他东西。

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

//create the date picker

document.getElementById('dt1picker').innerHTML="<input type='hidden' id='datePicker'>"
$("#datePicker").datepicker(pickerOptions);
**$("#datePicker").datepicker("setDate", "0d");**