Focal Point
Display Parent and child data

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

March 10, 2006, 01:35 AM
<Antony Gubert>
Display Parent and child data
I have a report which displays the following 4 columns.

Dept.No Dept.Name No.of Emp Tot.Sal

The Dept.No column has a href link.

The requirement is, on click of Dept no, report should list all the employees details for the selected department on the same page.

For example, if user clicks on First record’s Dept no, report should make space between first and second record and display the employee details for the selected department.

Thanks
March 10, 2006, 05:14 AM
<JG>
What you need is the new 713 Active HTML report format, but its not a free option.
March 10, 2006, 08:35 AM
Tony A
Antony,

You could use a combination of javascript and HTML to achieve this. This code will require tweaking to provide the shiny end product but it gives you a starting point -

SET PAGE-NUM = NOPAGE
DEFINE FILE GGSALES
  CHILDDIV/A300 = '<a href="javascript:ShowChild('''||REGION||''');">'||REGION||
                  '</a><div id="'||REGION||'" style="visibility: hidden;"></div>';
END
TABLE FILE GGSALES
SUM DOLLARS
BY CHILDDIV AS 'Region'
ON TABLE HOLD AS REGIONS FORMAT HTMTABLE
END
-RUN
-HTMLFORM BEGIN
<html>
<head>
<title>Parent and Child</title>
</head>
<script language=javascript>
function ShowChild(region) {
//alert(region);
  this.displayElement=document.getElementById(region);
  if (this.displayElement.style.visibility == "visible") {
    this.displayElement.innerHTML = '';
    this.displayElement.style.visibility = "hidden";
  } else {
    this.displayElement.innerHTML = '<iframe src="/cgi-bin/ibi_cgi/ibiweb.exe?'+
                                    'IBIAPP_app=baseapp&|IBIF_ex=rgnlist&|Region='+
                                    region+'"></iframe>';
    this.displayElement.style.visibility = "visible";
  }
}
</script>
<body>
!IBI.FIL.REGIONS;
</body>
</html>
-HTMLFORM END


You will require a fex called rgnlist to make this work, something like -

-DEFAULT &Region='FOC_NONE'
SET PAGE-NUM = NOPAGE
TABLE FILE GGSALES
SUM DOLLARS
 BY ST
WHERE REGION EQ '&Region'
END



Enjoy .........

T

This message has been edited. Last edited by: Tony A,



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
March 10, 2006, 08:51 AM
susannah
FOC_NONE, with underscore, yes? T?




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
March 10, 2006, 09:12 AM
Tony A
Susannah,

Well spotted! No prizes though I am afraid Frowner

Now corrected. Smiler

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
March 10, 2006, 10:17 AM
mgrackin
You may also want to look inot the new ACCORDIAN report feature in WebFOCUS 7.

Try this to see how it works:

TABLE FILE EMPDATA
PRINT FIRSTNAME TITLE SALARY
BY DEPT
BY LASTNAME
ON TABLE SET EXPANDABLE ON
END


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
March 10, 2006, 11:21 AM
<JG>
Tony's method opens in an iframe

I think its much better to generate the whole thing and you do not have to worry about those awful scroll bars.

The ACCORDIAN reports are the active HTML reports and as I said not FOC.


FILEDEF DISPLAYFILE DISK DISPFILE.HTM
-RUN
DEFINE FILE CAR
BLANK/A1=' ';
COUNTRYLABEL/A180='' || '
' || COUNTRY | '
';
CARDISPLAY/A180='';
TDBODYH/A180='';
TDBODYF/A180='
' || CAR || '
';
END

TABLE FILE CAR
PRINT
CARDISPLAY AS ''
BY COUNTRYLABEL NOPRINT
ON COUNTRYLABEL SUBHEAD
""ON COUNTRYLABEL SUBFOOT
"ON TABLE HOLD AS DISPLAYFILE FORMAT WP
ON TABLE SET PAGE NOPAGE
ON TABLE SET PANEL 300
ON TABLE SET WIDTH 180
END
-RUN
-HTMLFORM BEGIN


<script>
function toggle(Country)
{
var el;
if (document.getElementById
&& (el = document.getElementById(Country)))
{
if(el.style.display == 'none' ){
el.style.display = '';
}else{
el.style.display = 'none';
}
}
}




!IBI.FIL.DISPFILE;



-HTMLFORM END

This message has been edited. Last edited by: <Mabel>,
March 13, 2006, 05:10 AM
<Antony Gubert>
Thanks all.

Given solution is working well. Is it possible to go multiple levels?

Please let me know.

Thanks
March 13, 2006, 07:46 AM
Tony A
JG,

Nice application! I agree the scroll bars are annoying but it was a quick method!! I prefer your method, as you imply, it doesn't require a revisit to the reporting server everytime you open the iframe.

Antony,

Anything is possible, you just have to get your head around the requirements!

Try creating the HTML and Javascript first and then gear it into the WebFOCUS.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
March 13, 2006, 09:17 AM
Tony A
One modification that I would suggest is to change the cursor style when the cursor is over the country value by using something like
COUNTRYLABEL/A180='<table><tr onClick="toggle[' || '''' || COUNTRY || '''' || ');">'
     || '<td onMouseOver="this.style.cursor=''hand''">' || COUNTRY | '</td></tr></table><table>';


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
March 13, 2006, 01:30 PM
<JG>
Thanks Tony and I like the mouseover idea.

With regards expanding to multiple levels.

The main issue providing you stay within the WebFocus limitations for heading/subhead/subfoot text which used to be 32k
(not sure what it is now) Is that you cannot nest tbody tags which means that you have to look at more extensive javascript and use the getELementsByTagName method.

This example goes down an extra level and can be expanded quite easily (I've included Tonys mouseover)
I've also included indentation of the drill items.

The only issue is that when you close a drilldown you must close the children first or they are left hanging. If anyone has a solution I'm open


FILEDEF DISPLAYFILE DISK DISPFILE.HTM
-RUN
DEFINE FILE CAR
COUNTRYLABEL/A256='' || '' || COUNTRY | '';
CARLABEL/A256 ='' || '' || CAR | '';
MODDISPLAY/A256='' || MODEL || '';
END

TABLE FILE CAR
PRINT
MODDISPLAY AS ''
BY COUNTRYLABEL NOPRINT
ON COUNTRYLABEL SUBHEAD
"BY CARLABEL NOPRINT
ON CARLABEL SUBHEAD
"ON TABLE HOLD AS DISPLAYFILE FORMAT WP
ON TABLE SET PAGE NOPAGE
ON TABLE SET PANEL 300
ON TABLE SET WIDTH 180
END
-RUN
-HTMLFORM BEGIN



<script>
function toggle( ToggleWhat )
{
var divs = document.getElementsByTagName('tr');
for (var i = 0; i < divs.length; i++)
{
var element = divs[i];
if( element.className.indexOf( ToggleWhat ) != -1 )
{
if(element.style.display == 'none' ){
element.style.display = '';
}else{
element.style.display = 'none';
}
}
}
}



!IBI.FIL.DISPFILE;





-HTMLFORM END

This message has been edited. Last edited by: <Mabel>,
March 14, 2006, 07:35 AM
<Antony Gubert>
Thanks all for the solution.