Focal Point
[SOLVED] Problem with focexec drill to same file using an anchor or window location

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

January 21, 2011, 11:25 AM
trob
[SOLVED] Problem with focexec drill to same file using an anchor or window location
I am trying to drill to the same file and include an anchor so the selected record is at the top of the page after the drilldown. My problem is within the FOCEXEC command if i try to use # to select the anchor it is getting encoded to the URL-encoding %23. Can anyone help me with this?

So my link looks like:
http://localhost:8080/ibi_apps...=&COUNTER=52&RECSEL=%2352

instead of:
http://localhost:8080/ibi_apps...=&COUNTER=52&RECSEL=#52

-* File CARTEST.fex
-* File CARTEST.fex
TABLE FILE CAR
PRINT 
  COMPUTE COUNTER/I2 = LAST COUNTER + 1; NOPRINT
  COMPUTE RECNUM/A50 = '<A NAME="'|EDIT(COUNTER)|'">'|EDIT(COUNTER)|'</A>';
  COMPUTE RECSEL/A10 = '#' | EDIT(COUNTER); NOPRINT
  COUNTRY
  CAR
  MODEL
  BODYTYPE
ON TABLE NOTOTAL
ON TABLE SET STYLE *
TYPE=DATA,
     COLUMN=N4,
     FOCEXEC=CARTEST( \
     COUNTER \
     RECSEL \
     ),
$
ENDSTYLE
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
END

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


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
January 21, 2011, 11:55 AM
Francis Mariani
I don't know how to solve the # problem, but here's an example of what I think you want to do - the clicked-on row becomes the first row (retaining its row number).

-* File fmtestcar1.fex

-DEFAULT &COUNTER = 0;

TABLE FILE CAR
PRINT 
  COMPUTE COUNTER/I2 = LAST COUNTER + 1; NOPRINT
  COMPUTE RECNUM/A50 = '<A NAME="'|EDIT(COUNTER)|'">'|EDIT(COUNTER)|'</A>';
  COUNTRY
  CAR
  MODEL
  BODYTYPE

COMPUTE SORT_ORDER/I2 = IF COUNTER EQ &COUNTER THEN 1 ELSE 2; NOPRINT

BY TOTAL SORT_ORDER NOPRINT

ON TABLE NOTOTAL
ON TABLE SET STYLE *
TYPE=DATA,
     COLUMN=COUNTRY,
     FOCEXEC=FMTESTCAR1( \
     COUNTER \
     ),
$
ENDSTYLE
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
END




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
January 21, 2011, 12:18 PM
trob
Sorry Francis, actually I'm trying to keep the sort order the same. The actual application where I am using this I am opening a subfoot with a report in it in an accordian type fashion. Once the accordian is open I want to make it the top of the page but still in the same order, I don't need records moving around. So this is why I am trying to use the basic HTML anchor within my drill link.


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
January 21, 2011, 12:27 PM
Francis Mariani
quote:
I want to make it the top of the page but still in the same order

I don't understand this.


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
January 21, 2011, 01:30 PM
trob
I guess I don't really mean top of the page, rather top of the screen. Basically I want the page to be scrolled down with the selected record at the top of the screen.


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
January 21, 2011, 03:01 PM
Francis Mariani
Works when using Javascript:

-* File fmtestcar11.fex

TABLE FILE CAR
PRINT
  COMPUTE COUNTER/I2 = LAST COUNTER + 1; NOPRINT
  COMPUTE RECNUM/A50 = '<A NAME="'|EDIT(COUNTER)|'">'|EDIT(COUNTER)|'</A>';
  COUNTRY
  CAR
  MODEL
  BODYTYPE
ON TABLE NOTOTAL
ON TABLE SET STYLE *
TYPE=DATA,
     COLUMN=COUNTRY,
     javascript=runReport(COUNTER), $
ENDSTYLE

ON TABLE HOLD AS H001 FORMAT HTMTABLE

MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
END
-RUN

-HTMLFORM BEGIN
<script type="text/javascript">
function runReport(COUNTER)
{
loc  = "/ibi_apps/WFServlet";
loc += "?IBIF_focexec=FMTESTCAR11";
loc += "#" + COUNTER;

location = loc;
}
</script>
!IBI.FIL.H001;
-HTMLFORM END



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
January 21, 2011, 03:03 PM
GamP
Then try it like this (taking your example):
TABLE FILE CAR
PRINT 
  COMPUTE COUNTER/I2 = LAST COUNTER + 1; NOPRINT
  COMPUTE RECSEL/A60 = '<A NAME="'|EDIT(COUNTER)|'"></A><a href=#' | EDIT(COUNTER) | '>' | EDIT(COUNTER) | '</a>'; 
  COUNTRY
  CAR
  MODEL
  BODYTYPE
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTMTABLE
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
END



GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
January 21, 2011, 03:45 PM
trob
Francis, I got that to work using javascript. I was just wondering if there was any other way using FOCEXEC. I'll just go with javascript for now.

-* File CARTEST.fex
SET HOLDLIST = PRINTONLY
SET ASNAMES = FOCUS
SET TITLE = OFF
SET EMPTYREPORT = OFF
SET PAGE-NUM = NOPAGE

-SET &THISEXEC = EDIT(&FOCFOCEXEC,'$999999999999999');
-SET &RNDM = EDIT(HHMMSS('A8'),'99$99$99');

-DEFAULTS &COUNTER = 0;

-IF &COUNTER GT 0 THEN GOTO CAR2

TABLE FILE CAR
PRINT
  COMPUTE COUNTER/I2 = LAST COUNTER + 1;
  COMPUTE RECNUM/A50 = '<A NAME="'|EDIT(COUNTER)|'">'|EDIT(COUNTER)|'</A>';
  COMPUTE OPENSUBFOOT/A1 = '+';
  COUNTRY
  CAR
  MODEL
  BODYTYPE
ON TABLE HOLD AS FOCCACHE/CAR2 FORMAT ALPHA
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
END
-RUN

-IF &COUNTER EQ 0 THEN GOTO RPT;
-CAR2

DEFINE FILE FOCCACHE/CAR2
 OPENSUBFOOT1/A1 = IF &COUNTER EQ 0 THEN '+'
	ELSE IF OPENSUBFOOT EQ '+' AND COUNTER EQ &COUNTER THEN '-'
    ELSE IF COUNTER EQ &COUNTER THEN '+'
	ELSE OPENSUBFOOT;
END

TABLE FILE FOCCACHE/CAR2
PRINT
  COUNTER
  RECNUM
  OPENSUBFOOT1 AS OPENSUBFOOT
  COUNTRY
  CAR
  MODEL
  BODYTYPE
ON TABLE HOLD AS FOCCACHE/CAR2 FORMAT ALPHA
END

-RPT
TABLE FILE FOCCACHE/CAR2
PRINT
  COUNTER AS ''
  COMPUTE RECNUM/A50 = '<A NAME="'|EDIT(COUNTER)|'"></A>'; AS ''
  COUNTRY
  CAR
  MODEL
  BODYTYPE
BY COUNTER NOPRINT
BY OPENSUBFOOT AS ' '
ON OPENSUBFOOT SUBFOOT
" "
" "
"THIS ROW HAS BEEN OPENED"
" "
" "
WHEN OPENSUBFOOT EQ '-';
ON TABLE SET LINES 500
ON TABLE NOTOTAL
ON TABLE SET STYLE *
     UNITS=IN,
     SQUEEZE=ON,
     GRID=ON,
     ORIENTATION=LANDSCAPE,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='TIMES NEW ROMAN',
     SIZE=11,
     STYLE=NORMAL,
     RIGHTGAP=0.1000,
     LEFTGAP=0.1000,
$
TYPE=DATA,
     COLUMN=N2,
	 STYLE=-UNDERLINE,
     JAVASCRIPT=RunURL( 'cartest' COUNTER &RNDM ),
$
ENDSTYLE
END

-HTMLFORM BEGIN
<script type="text/javascript" language="JavaScript">
function RunURL(parm1, parm2, parm3)
{
myServlet = '/ibi_apps/WFServlet?';
myURL = myServlet + '&|IBIF_ex=' + parm1 + '&|CLICKED_ON=' + '&|COUNTER=' + parm2 + '&|RNDM=' + parm3 + '#' + parm2;
location.href = myURL;
}
</script>
-HTMLFORM END
-EXIT



------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
February 02, 2011, 01:54 PM
trob
After moving on I decided I did not like the functionality of the anchor because it always opened/moved it to the top of the page. I wanted the page to reload in the same position so since I was already using javascript to drill I figured out a better way of doing this. I thought I might as well share my final results.

-* File CARTEST1.fex
SET HOLDLIST = PRINTONLY
SET ASNAMES = FOCUS
SET TITLE = OFF
SET EMPTYREPORT = OFF
SET PAGE-NUM = NOPAGE

-SET &THISEXEC = EDIT(&FOCFOCEXEC,'$999999999999999');
-SET &RNDM = EDIT(HHMMSS('A8'),'99$99$99');

-DEFAULTS &COUNTER = 0;
-DEFAULTS &MYLOC = 0;

-IF &COUNTER GT 0 THEN GOTO CAR2

TABLE FILE CAR
PRINT
  COMPUTE COUNTER/I2 = LAST COUNTER + 1;
  COMPUTE RECNUM/A50 = '<A NAME="'|EDIT(COUNTER)|'">'|EDIT(COUNTER)|'</A>';
  COMPUTE OPENSUBFOOT/A1 = '+';
  COUNTRY
  CAR
  MODEL
  BODYTYPE
ON TABLE HOLD AS FOCCACHE/CAR2 FORMAT ALPHA
MORE
FILE CAR
MORE
FILE CAR
MORE
FILE CAR
END
-RUN

-IF &COUNTER EQ 0 THEN GOTO RPT;
-CAR2

DEFINE FILE FOCCACHE/CAR2
 OPENSUBFOOT1/A1 = IF &COUNTER EQ 0 THEN '+'
 ELSE IF OPENSUBFOOT EQ '+' AND COUNTER EQ &COUNTER THEN '-'
    ELSE IF COUNTER EQ &COUNTER THEN '+'
 ELSE OPENSUBFOOT;
END

TABLE FILE FOCCACHE/CAR2
PRINT
  COUNTER
  RECNUM
  OPENSUBFOOT1 AS OPENSUBFOOT
  COUNTRY
  CAR
  MODEL
  BODYTYPE
ON TABLE HOLD AS FOCCACHE/CAR2 FORMAT ALPHA
END

-RPT
TABLE FILE FOCCACHE/CAR2
PRINT
  COUNTER AS ''
  COMPUTE RECNUM/A50 = '<A NAME="'|EDIT(COUNTER)|'"></A>'; AS ''
  COUNTRY
  CAR
  MODEL
  BODYTYPE
BY COUNTER NOPRINT
BY OPENSUBFOOT AS ' '
ON OPENSUBFOOT SUBFOOT
" "
" "
"THIS ROW HAS BEEN OPENED"
" "
" "
WHEN OPENSUBFOOT EQ '-';
ON TABLE SET LINES 500
ON TABLE NOTOTAL
ON TABLE HOLD AS HTMLCAR2 FORMAT HTML
ON TABLE SET STYLE *
     UNITS=IN,
     SQUEEZE=ON,
     GRID=ON,
     ORIENTATION=LANDSCAPE,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='TIMES NEW ROMAN',
     SIZE=11,
     STYLE=NORMAL,
     RIGHTGAP=0.1000,
     LEFTGAP=0.1000,
$
TYPE=DATA,
     COLUMN=N2,
     STYLE=-UNDERLINE,
     JAVASCRIPT=RunURL( 'cartest1' COUNTER &RNDM ),
$
ENDSTYLE
END

-HTMLFORM BEGIN
<script type="text/javascript" language="JavaScript">
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function RunURL(parm1, parm2, parm3) {
     myLocation = f_scrollTop();
     myServlet = '/ibi_apps/WFServlet?';
     myURL = myServlet + '&|IBIF_ex=' + parm1 + '&|CLICKED_ON=' + '&|COUNTER=' + parm2 + '&|RNDM=' + parm3 + '&|MYLOC=' + myLocation;
     location.href = myURL;
}
</script>
!IBI.FIL.HTMLCAR2;
<script type="text/javascript" language="JavaScript">
var OrigOnLoad = document.body.onload;
document.body.onload = ScrollFx;
function ScrollFx()
{
  if (OrigOnLoad) OrigOnLoad ();
  window.scrollTo(0,&MYLOC);
}
</script>
-HTMLFORM END
-EXIT



------------------------------------------
DevStudio 8.2.03
WFS 8.2.03