Focal Point
[SOLVED]Setting focus on double list control in AS8009

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4967060286

April 28, 2016, 10:47 AM
SeyedG
[SOLVED]Setting focus on double list control in AS8009
Hi all,
Does anyone know how to set focus on a double list control in App Studio 8009? This is for a guided report where the user selects columns, sort, report title and report format. I am limiting the number of columns selected for PDF format to 9 to prevent paneling error. After displaying a message, I like to have the focus on the double list for selecting columns.

Thank you,

Seyed

This message has been edited. Last edited by: SeyedG,
April 28, 2016, 11:17 AM
Squatch
Plain old JavaScript:

alert("Display message to user");
document.getElementById("customselect1_selectfrom").focus();

jQuery:

alert("Display message to user");
$("#customselect1_selectfrom").focus();

To have the focus go to the right side of the double list control, use "customselect1_selectto" instead.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
April 28, 2016, 11:45 AM
SeyedG
quote:
Squatch

Hi Squatch,
Thank you for your help. Here is the result of my changes:

Method #1: The following doesn't work, it proceeds to run the report in PDF format and crashes with paneling error.
if (rpt_fmt == 'PDF' && total_columns > 9) {
    alert('For PDF Reports, The Maximum Number Of Columns Is 9!');
   document.getElementById("customselect5").focus();
   return false;
}


Method #2: The following doesn't crash, and stays on the guided report page. But, there is no focus anywhere on the page.
if (rpt_fmt == 'PDF' && total_columns > 9) {
    alert('For PDF Reports, The Maximum Number Of Columns Is 9!');
    form1.customselect5.focus();
    return false;
}


Method #3: And finally using the JQuery method you suggested, code is ignored and guided report proceeds with running the report in PDF format and crashes with paneling error.
if (rpt_fmt == 'PDF' && total_columns > 9) {
    alert('For PDF Reports, The Maximum Number Of Columns Is 9!');
    alert("Display message to user");
    $("#customselect5").focus();
    return false;
}



Thanks again,


Seyed


WebFOCUS 8.0.09
App Studio 8009
Linux Kernel-2.6
DBMS: Oracle 11g
all output (Excel, HTML, AHTML, PDF)
April 28, 2016, 11:57 AM
Squatch
The "customselect5" id is the id of the entire double list control.

There are separate id's for the selection boxes. The id of the one you want the focus on is "customselect5_selectfrom".


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
April 28, 2016, 01:17 PM
Squatch
And if you want to stop the report from running, you can do so in the "onclick" event for the submit button. Just call on the "stopImmediatePropagation" function inside the "event" object:

// Assume "rpt_fmt" and "total_columns" are
// global variables that are set elsewhere...

function form1Submit_onclick(event) {

    if (rpt_fmt == 'PDF' && total_columns > 9) {
        alert('For PDF Reports, The Maximum Number Of Columns Is 9!');
        document.getElementById("customselect5_selectfrom").focus();
        event.stopImmediatePropagation();
        return;
    }

}



App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
April 28, 2016, 01:34 PM
SeyedG
Hi Squatch,
Your last solution worked perfectly!. Without the event.stopImmediatePropagation line, it still would crash, but using it, stops the guided report from running the PDF report and puts the focus on the 'customselect5_selectfrom' box.

Thank you very much,

Seyed


WebFOCUS 8.0.09
App Studio 8009
Linux Kernel-2.6
DBMS: Oracle 11g
all output (Excel, HTML, AHTML, PDF)