I would like to extend this technique, and insert an Active Report into a DIV tag.
Here is my report focexec - carahtmlrpt:
-DEFAULT &COUNTRY = 'FOC_NONE'
APP PREPENDPATH IBISAMP
TABLE FILE CAR
SUM
DEALER_COST
BY COUNTRY
BY CAR
BY MODEL
WHERE COUNTRY EQ '&COUNTRY' ;
ON TABLE PCHOLD FORMAT AHTMLTAB
ON TABLE SET STYLE *
TYPE=REPORT, FONT='TAHOMA', SIZE=9 ,$
ENDSTYLE
END
Here is my calling focexec:
-HTMLFORM BEGIN
<!DOCTYPE html>
<html>
<head>
<title>Demo jQuery / WebFOCUS</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
var _url = "http://yourservernamehere/ibi_apps/WFServlet?IBIF_ex=";
var _ibiapp = "testcode/";
var _procedure = "carahtmlrpt";
function getReport() {
$.ajax({
type : "GET",
url : _url + _ibiapp + _procedure + "&" + "rnd=" + Math.random(),
data : "COUNTRY=" + $("#country").val(),
dataType: "html",
success : function(_data) {
$("#content").empty();
$("#content").append(_data);
}
});
}
</script>
</head>
<body id="body">
!IBI.OBJ.ACTIVEREPORTJS;
<select id="country">
<option value="FOC_NONE"> -- All -- </option>
<option value="ITALY"> Italy </option>
<option value="ENGLAND"> England </option>
<option value="W GERMANY"> W Germany </option>
</select>
<button onclick="getReport();">getReport</button>
<div id="content" style="position:absolute; left:200px; top:100px;">
[Report will go here.]
</div>
</body>
</html>
-HTMLFORM END
Note that the code assumes the application folder is 'testcode', and you would need to 'add your server name'.
When I clck run the report does not appear on the page.
When I capture network activity, via Programming Tools (I am on IE), I do see the Active Report code being returned AOK.
I think I am on the right track, as this focexec displays the Active Report within the DIV tag AOK:
APP PREPENDPATH IBISAMP
TABLE FILE CAR
SUM
DEALER_COST
BY COUNTRY
BY CAR
BY MODEL
ON TABLE HOLD AS HLDRPT FORMAT AHTMLTAB
ON TABLE SET STYLE *
TYPE=REPORT, FONT='TAHOMA', SIZE=9 ,$
ENDSTYLE
END
-*
-HTMLFORM BEGIN
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body id="body">
Here is your report..
!IBI.OBJ.ACTIVEREPORTJS;
<div id="content" style="position:absolute; left:200px; top:100px;">
!IBI.FIL.HLDRPT;
</div>
</body>
</html>
-HTMLFORM END
I am thinking there must be some amendments required to the jQuery/Ajax code, that will support the code returned by AHTMLTAB.This message has been edited. Last edited by: David Briars,
Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
December 17, 2014, 02:09 PM
Francis Mariani
Hmmm, I'd be very surprised that you can retrieve an Active HTML report (AHTMLTAB) from an Ajax call.
I noticed you include jQuery in your HTML, so perhaps the issue is multiple versions of jQuery. I posted a tip here. Try either removing your reference to jQuery or use the conflict avoidance technique.
If this doesn't work, I'd put the Active HTML report in an iframe and make that iframe the target of a regular fex call (non-Ajax).
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
December 20, 2014, 03:06 PM
<FreSte>
David,
I agree with Francis. In your fex, the AHTMLTAB report that is being generated is a full-blown HTML-page (including the
<html> and </html>
tags. Putting that HTML-page in a div is not desirable.
I think adding an iframe and loading the report in that iframe is the easiest way to do it. I copied below a small example with an iframe in a jQuery dialog with iframe (using the same fex) Hope this will help,
@Francis – Thank you for your comments. I see now that the original technique (ajax) for inserting an HTML report into a DIV tag, cannot be extended to Active Reports.
@Fred – Thank you for your excellent demo/model. It works wonderfully in my environment.
I agree that setting the Active Report URL, to the SRC attribute of an IFRAME tag, is the way to go. The fact that you can control the how the report appears within the host page, via DIV tag settings, is exactly what I was after. :-)This message has been edited. Last edited by: David Briars,