Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED]Reset Calendar Control

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED]Reset Calendar Control
 Login/Join
 
Gold member
posted
I'm having a hard time getting the calendar control to reset on one of my forms. I have searched the forum and used some of the javascript that I ran across to reset the value and it appears to clear the field, but if I run the form after clearing it, the date value that was previously populated is still sent to the report. I would like for it to send a _FOC_NULL value as if the form was just loaded.

Does anyone have any code or suggestions on how to do this? Here's what I have tried using without any luck:
 function cmdReset2_onclick(ctrl) {
document.getElementById('calendar1').value=null;
document.getElementById('calendar2').value=null;
document.getElementById('calendar3').value=null;
document.getElementById('calendar4').value=null;
} 


Thanks,
Clint

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


WF 8.2.0.3
Windows 10 64bit
HTML, AHTML, PDF, Excel
 
Posts: 83 | Registered: April 13, 2015Report This Post
Expert
posted Hide Post
Use the IBI so-called API functions. here's an example:

IbComposer_setCurrentSelection('calendar1', '_FOC_NULL')


I'm not sure how that _FOC_NULL value is depicted in a calendar control. Instead of _FOC_NULL, I would use whatever you have as the default value, perhaps no value, then use ''.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Gold member
posted Hide Post
Thanks Francis, that command seemed to work with _FOC_NULL

However, the two single quotes didn't work for the null value. The _FOC_NULL works and gets passed correctly, but when I tried '' it wouldn't clear the controls. Having _FOC_NULL looks pretty ugly in the control, so I'm curious if there is a way to mask it with a blank but still send _FOC_NULL.


WF 8.2.0.3
Windows 10 64bit
HTML, AHTML, PDF, Excel
 
Posts: 83 | Registered: April 13, 2015Report This Post
Expert
posted Hide Post
Do you know what the initial value is? Perhaps it can be saved in a hidden text control, which you then use as the reset value.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Master
posted Hide Post
I was just in the same situation and found a solution that works. In my situation, there are two date ranges that the user can choose from. It can be the first date range or the second date range or both. There must be at least one date range selected, and one part of the range cannot be unselected (e.g., a start date but no end date).

I made all four of my calendar controls read-only. Then in the JavaScript "window_onload" function in App Studio, I set the date values to just a single space character each. This ensures that nothing in the calendar control is visible to the user when there is no date selected, BUT this space character can be tested in my FEX file to change the way the report is generated (More on that further below).

Here is the window_onload code:

//Begin function window_onload
function window_onload() {

UpdateData();
// TODO: Add your event handler code here
//add onInitialUpdate() function to make changes before initial run of the reports

//Set calendar controls to just a space character
IbComposer_setCurrentSelection('calendar1', ' ');
IbComposer_setCurrentSelection('calendar2', ' ');
IbComposer_setCurrentSelection('calendar3', ' ');
IbComposer_setCurrentSelection('calendar4', ' ');
}
//End function window_onload


When a user clicks the Run button to generate the report, the date range(s) must be checked for correctness:

//Begin function form8Submit_onclick
function form8Submit_onclick(event) {
var eventObject = event ? event : window.event;
var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;
// TODO: Add your event handler code here
    var date1 = IbComposer_getCurrentSelection("calendar1");
    var date2 = IbComposer_getCurrentSelection("calendar2");
    var date3 = IbComposer_getCurrentSelection("calendar3");
    var date4 = IbComposer_getCurrentSelection("calendar4");
    if (date1 == " " && date2 == " " && date3 == " " && date4 == " " ) {
        alert("Please select at least one date range");
        event.stopImmediatePropagation();
        return;
    }
    var bmdyy = IbComposer_getCurrentSelection("calendar1");
    var emdyy = IbComposer_getCurrentSelection("calendar2");
    if ((bmdyy != " " && emdyy == " ") || (bmdyy == " " && emdyy != " ")) {
        alert("Incomplete Arrival date range");
        event.stopImmediatePropagation();
        return;
    } else {
        var byymd = bmdyy.toString().substr(4,4) + bmdyy.toString().substr(0,4);
        var eyymd = emdyy.toString().substr(4,4) + emdyy.toString().substr(0,4);
        if (eyymd < byymd) {
            alert("Arrival date start cannot be greater than Arrival date end");
            event.stopImmediatePropagation();
            return;
        }
    }
    bmdyy = IbComposer_getCurrentSelection("calendar3");
    emdyy = IbComposer_getCurrentSelection("calendar4");
    if ((bmdyy != " " && emdyy == " ") || (bmdyy == " " && emdyy != " ")) {
        alert("Incomplete Discharge date range");
        event.stopImmediatePropagation();
        return;
    } else {
        var byymd = bmdyy.toString().substr(4,4) + bmdyy.toString().substr(0,4);
        var eyymd = emdyy.toString().substr(4,4) + emdyy.toString().substr(0,4);
        if (eyymd < byymd) {
            alert("Discharge date start cannot be greater than Discharge date end");
            event.stopImmediatePropagation();
            return;
        }
    }
}
//End function form8Submit_onclick


I have two buttons next to each date range, and each one is named "Clear". This allows the user to "remove" a date range by putting the space characters back into the calendar controls:

//Begin function button1_onclick
function button1_onclick(event) {
var eventObject = event ? event : window.event;
var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;
// TODO: Add your event handler code here
    IbComposer_setCurrentSelection('calendar1', ' ');
    IbComposer_setCurrentSelection('calendar2', ' ');
}
//End function button1_onclick

//Begin function button2_onclick
function button2_onclick(event) {
var eventObject = event ? event : window.event;
var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;
// TODO: Add your event handler code here
    IbComposer_setCurrentSelection('calendar3', ' ');
    IbComposer_setCurrentSelection('calendar4', ' ');
}
//End function button2_onclick


Now here is what happens in the FEX file after the user clicks the Run button... The dates are being passed as strings in MMDDYYYY format, because the users expect to see it that way in the calendar control. But I need them in YYYYMMDD string format because the dates are stored year-month-day in SQL Server. I use the space character test to know if the user selected dates or not. If so, convert to YYYYMMDD format:

-IF &START_DATE_IN EQ ' ' GOTO DATE2;
-SET &START_DATE = DATECVT(DATECVT(&START_DATE_IN.Start date:., 'I8MDYY', 'YYMD'), 'YYMD', 'I8YYMD');
-DATE2

-IF &END_DATE_IN EQ ' ' GOTO DATE3;
-SET &END_DATE = DATECVT(DATECVT(&END_DATE_IN.End date:., 'I8MDYY', 'YYMD'), 'YYMD', 'I8YYMD');
-DATE3

-IF &START_DISCHARGE_IN EQ ' ' GOTO DATE4;
-SET &START_DISCHARGE = DATECVT(DATECVT(&START_DISCHARGE_IN.Discharge date start:., 'I8MDYY', 'YYMD'), 'YYMD', 'I8YYMD');
-DATE4

-IF &END_DISCHARGE_IN EQ ' ' GOTO DATE5;
-SET &END_DISCHARGE = DATECVT(DATECVT(&END_DISCHARGE_IN.Discharge date end:., 'I8MDYY', 'YYMD'), 'YYMD', 'I8YYMD');
-DATE5


I have more conditional tests in the FEX file's WHERE section to see which date range (or possibly both) to use:

WHERE
-IF &START_DATE_IN EQ ' ' GOTO NOGO1;
	( ED_HISTORY_DATA_V.ED_HISTORY_DATA_V.ARRIVAL_DT FROM DT(&START_DATE.000000000000) TO DT(&END_DATE.235959999999)) AND
-NOGO1
-IF &START_DISCHARGE_IN EQ ' ' GOTO NOGO2;
	( ED_HISTORY_DATA_V.ED_HISTORY_DATA_V.DISCHARGE_DT FROM DT(&START_DISCHARGE.000000000000) TO DT(&END_DISCHARGE.235959999999))
-NOGO2


And that's it.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Gold member
posted Hide Post
Thanks for sharing! I think that is what I ultimately ended up doing as well. Passing a space and then doing -SET &STARTDATE2 = IF &STARTDATE1 EQ ' ' THEN _FOC_NULL ELSE &STARTDATE1

Clint


WF 8.2.0.3
Windows 10 64bit
HTML, AHTML, PDF, Excel
 
Posts: 83 | Registered: April 13, 2015Report This Post
Master
posted Hide Post
No problem capples. I came across this thread a couple of days ago looking for a solution that didn't involve _FOC_NULL showing up in the calendar control. This was the best I could come up with.

This thread should probably be marked as SOLVED instead of CLOSED.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED]Reset Calendar Control

Copyright © 1996-2020 Information Builders