Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Setting Start Values in Calendar Controls
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Setting Start Values in Calendar Controls
 Login/Join
 
Gold member
posted
I'm having a hard time setting the initial values for a Start and End date set of calendar controls. Start date needs to be a year before today, so it's computed. The only way to get a value into the control is by using a fex from the Requests zone and you would think that this would be easy. First of, as an aside, I don't see why a fex should be necessary. Why should I have to connect to a database just to set a couple of constants?

Currently my fex looks like this, although this has been evolving:

TABLE FILE CMSBESTPRACTICESDATA
SUM
COMPUTE ONEYEARAGO/MDYY = DTADD( '&YYMD', YEAR, -1 );
COMPUTE CURRENTDATE/MDYY = '&YYMD';
BY HIGHEST 1 SCHED_START_DT
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLEMBEDIMG ON
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/warm.sty,
$
ENDSTYLE
END

Please don't tell me that I can set the current date part by checking the box in Settings. I know this. That isn't the problem.

This message has been edited. Last edited by: mbondr,


WebFOCUS 8.2.04 (and climbing)
Windows 10, AppStudio
 
Posts: 84 | Registered: February 08, 2018Reply With QuoteReport This Post
Guru
posted Hide Post
You can use javascript in your HTML page. Here's some that I stole and modified.

Use this in a WebFocus HTML Launch page if you need to default a calendar control to the first
or last day of the current month. substitute your control names for "cal_StartDate" and "cal_EndDate".

if(typeof(bRuntime) != 'undefined') {
// TODO: Add your inline runtime code here
}
//Begin function window_onload
function window_onload() {
UpdateData();
// TODO: Add your event handler code here
//
// This gets today's date into mm/dd/yyyy format
var today = new Date();
var mm = today.getMonth() + 1;
var dd = '01';
var yyyy = today.getFullYear ();
if (mm < 10)
{mm = '0' + mm};
var beginningOfMonth = mm + '/01/' + yyyy;
document.getElementById("cal_StartDate").value = beginningOfMonth;
var d = new Date();
m = d.getMonth(); //current month
y = d.getFullYear(); //current year
var lastday = new Date(y,m+1,0); //this is last day of current month
//break it up so we can show it in mm/dd/yyyy format
var lastmm = lastday.getMonth() + 1;
if (lastmm < 10)
{lastmm = '0' + lastmm};
var lastdd = lastday.getDate ();
var lastyyyy = lastday.getFullYear ();
var endOfMonth = lastmm + '/' + lastdd + '/' + lastyyyy;
document.getElementById("cal_EndDate").value = endOfMonth;
//add onInitialUpdate() function to make changes before initial run of the reports
}
//End function window_onload 


Webfocus 8
Windows, Linux
 
Posts: 251 | Location: Palm Coast, FL | Registered: February 05, 2010Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Fex to set the default dates
No need to have all these ON TABLE... and the output format must be XML
TABLE FILE CAR
SUM COMPUTE ONEYEARAGO /YYMD = DTADD(DT_CURRENT_DATE(), YEAR, -1);
    COMPUTE CURRENTDATE/YYMD = DT_CURRENT_DATE();
BY COUNTRY NOPRINT
WHERE READLIMIT   EQ 1;
WHERE RECORDLIMIT EQ 1;
ON TABLE PCHOLD FORMAT XML
END 
-RUN

Then add this fex as a Request & Data Source within your HTML
Associate the fex in the Settings of your Start calendar control as an Explicit (Request panel) and have the ONEYEARAGO in the "Value From" & "Display From"
Do the same for your End calendar control but with the CURRENTDATE in the "Value From" & "Display From"
Adjust both calendar range and other settings as you whish.

Other options may be available to set the default values, but depending on how your HTML is accessed, the options differ.


WF versions : Prod 8.2.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2233 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Gold member
posted Hide Post
Yay! Both techniques clearly laid out. I will make sure these are saved. Thanks!


WebFOCUS 8.2.04 (and climbing)
Windows 10, AppStudio
 
Posts: 84 | Registered: February 08, 2018Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Setting Start Values in Calendar Controls

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.