Spotfire当前日期输入栏中带日历弹出窗口 [英] Spotfire Current Date in input field with calendar popup

查看:437
本文介绍了Spotfire当前日期输入栏中带日历弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  HTML代码:
< span id =dt1>
< SpotfireControl id =a8b5b0d725bd41f385c3a859b511ae0b/>< / span>
< span id =dt1picker>< / span>

JS:
//选择后更新文档属性
function datePicker_onSelect(selectedDate){
// alert(selectedDate)
$(#dt1输入)。focus()
$(#dt1 input)。blur()
}

// jquery datepicker配置
//你可以评论buttonImageOnly和buttonImage行显示按钮而不是日历或您选择的图像。
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
}

//创建日期选择器
document.getElementById('dt1picker')。innerHTML =< input type ='隐藏'id ='datePicker'>
$(#datePicker)。datepicker(pickerOptions);
// - 我的代码在分析加载后立即获得当前日期。
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(今日);


解决方案

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



JScript:

 <$ c $ (); 
//或document.getElementById('hiddenBtn') .childNodes [0] .click();
}
$(document).ready(function(){executeScript()});
});

HTML:

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

HiddenButton上的IronPython脚本:



<$ p $系统导入的日期时间
来自Spotfire.Dxp.Data.DataType的
导入日期

$ b如果Document.Properties [OpenedYet] == False :
Document.Properties [udSelectedDate] = DateTime.Today.ToString(MM / dd / yyyy)
Document.Properties [OpenedYet] = True

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


With reference to http://spotfired.blogspot.in/2014/05/popup-calendar-webplayer-compatible.html. Can you please suggest how to get the current date in the input field as soon as the analysis is open in 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);

解决方案

I do this with a JScript and a Button (which I hide so nobody can see or click it).

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>

IronPython script on HiddenButton:

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

Mind you, this method can be kind of annoying for the developer, because every time you want to save the analytic, you need to go into document properties and switch the Property value of OpenedYet (which I have as a Boolean) from True to False and then you can't click anything else before you hit the save button.

这篇关于Spotfire当前日期输入栏中带日历弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆