Focal Point
EXPAND/COLLAPSE HEADER

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

March 17, 2008, 10:54 AM
vaayu
EXPAND/COLLAPSE HEADER
Can someone please help with any ideas to expand/collapse a portion of a report like HEADING or SUBHEAD. I have lot of information that needs to be flexible based on user/input..like a tree or expand/collapse button...

Open for any ideas..please let me know

Thanks


-********************
Sandbox: 8206.10
Dev: 8201M
Prod:8009
-********************
March 17, 2008, 11:01 AM
Tony A
PK,

It would be an idea to advise what output format you are wanting to use.

If it's HTML then use the search facility top right against the forum to locate previous posts containing EXPAND (such as this one).

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 17, 2008, 12:05 PM
vaayu
Tony,
Thanks for the response, I need the report in HTML format and the EXPAND only needs to be on the HEADING or SUBHEAD not for the columns..Im not sure if I can use Accordion reports to accomplish this..
Please help.
-Pawan


-********************
Sandbox: 8206.10
Dev: 8201M
Prod:8009
-********************
March 17, 2008, 12:29 PM
jodye
Hi

I am curious to see a response to this. I just added an option to some reports so that the user can decide whether or not to show headers and footers when the form is submitted. I just look at the amper and then skip the heading if that is what is wanted. But expanding/collapsing the heading would be great.


WF 8.0.0.5M
March 17, 2008, 12:30 PM
Tony A
Pawan,

I'm not suggesting that you try and use accordian reports, more to use a JavaScript method similar to those contained in the linked post. It should be a lot easier to do than columns as well.

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 17, 2008, 01:38 PM
Francis Mariani
Here's some quickly thrown together code that hides/shows heading lines.

It relies on 1 javaScript function, 2 CSS classes and 2 images.

I use HTML span tags around each Heading line - giving the Heading a CSS class. The image in line one of the heading is a + or a - and is the link you click on to hide/show the report heading.

This is quick and dirty - I'd like to be able to change the CSS class for all the heading lines in one command, at the moment, you must have "h99.className = 'PageHeadingShow';" and "h99.className = 'PageHeadingHide';" for each heading line.

DEFINE FILE CAR
TIMG/A150 = '<img id="imgToggle" src="/approot/baseapp/images/1.gif " ' |
            'width="9" height="9" onClick="fnToggle()" style="display: inline;">';
TSPAN1/A50 = '<span class=PageHeadingHide';
TSPAN2/A20 = '</span>';
END

TABLE FILE CAR
SUM
SALES
BY COUNTRY
ON TABLE HOLD AS H001 FORMAT HTMTABLE

HEADING
"<TIMG"
"<TSPAN1 id=h01>Heading Line 1 <TSPAN2"
"<TSPAN1 id=h02>Heading Line 2 <TSPAN2"

ON TABLE SET PAGE NOLEAD
END
-RUN

-HTMLFORM BEGIN
<script language="JavaScript">

function fnToggle()
{
if (h01.className == 'PageHeadingHide')
  {
  h01.className = 'PageHeadingShow';
  h02.className = 'PageHeadingShow';
  imgToggle.src = "/approot/baseapp/images/0.gif";
  }
else
  {
  h01.className = 'PageHeadingHide';
  h02.className = 'PageHeadingHide';
  imgToggle.src = "/approot/baseapp/images/1.gif";
  }
}
</script>
<style type="text/css">
.PageHeadingHide { display: none; }
.PageHeadingShow { display: inline; }
</style>

!IBI.FIL.H001;
-HTMLFORM END


You also need the following images, named
1.gif and
0.gif
respectively, added to the baseapp/images folder (or put them where you wish and change the TIMG define column accordingly.

Let me know if you have any questions. A 'view-source' will come in handy to see how things get translated.

Cheers,


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
March 17, 2008, 02:04 PM
Francis Mariani
Small improvement to the code, change the style of any number of heading lines in the JS function.

DEFINE FILE CAR
TIMG/A150 = '<img id="imgToggle" src="/approot/baseapp/images/1.gif " ' |
            'width="9" height="9" onClick="fnToggle()" style="display: inline;">';
TSPAN1/A50 = '<span class=PageHeadingHide';
TSPAN2/A20 = '</span>';
END

TABLE FILE CAR
SUM
SALES
BY COUNTRY
ON TABLE HOLD AS H001 FORMAT HTMTABLE

HEADING
"<TIMG"
"<TSPAN1 id=h01>Heading Line 1 <TSPAN2"
"<TSPAN1 id=h02>Heading Line 2 <TSPAN2"

ON TABLE SET PAGE NOLEAD
END
-RUN

-HTMLFORM BEGIN
<script language="JavaScript">

function fnToggle()
{

if (h01.className == 'PageHeadingHide')
  {
  imgToggle.src = "/approot/baseapp/images/0.gif";
  var spans = getElementsByClassName('PageHeadingHide');
  for(i=0; i <spans.length; i++)
    {
    spans[i].className = 'PageHeadingShow';
    }
  }
else
  {
  imgToggle.src = "/approot/baseapp/images/0.gif";
  var spans = getElementsByClassName('PageHeadingShow');
  for(i=0; i <spans.length; i++)
    {
    spans[i].className = 'PageHeadingHide';
    }
  }
}

function getElementsByClassName(className)
{
var all = document.all ? document.all : document.getElementsByTagName('*');
var elements = new Array();
for (var e = 0; e < all.length; e++)
  {
  if (all[e].className == className) elements[elements.length] = all[e];
  }
return elements;
}

</script>
<style type="text/css">
.PageHeadingHide { display: none; }
.PageHeadingShow { display: inline; }
</style>

!IBI.FIL.H001;
-HTMLFORM END



This uses a function that determines all the spans that have a particular class - amazingly there is no JS 'method' to determine this, as described here: http://domscripting.com/blog/display/18, so a function has to be written.


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
March 17, 2008, 02:05 PM
vaayu
Francis,
Thanks for the help....I will give it a try and find out...
-P


-********************
Sandbox: 8206.10
Dev: 8201M
Prod:8009
-********************
March 17, 2008, 02:59 PM
vaayu
Francis,
It works. That is exactly what I was looking for. Only thing its failing on me is when I put ON TABLE SET HTMLCSS ON to make use of my stylesheet...any ideas?

Thanks


-********************
Sandbox: 8206.10
Dev: 8201M
Prod:8009
-********************
March 17, 2008, 03:50 PM
Francis Mariani
Turning HTMLCSS on turns this:

<TR>
<TD>
<span class=PageHeadingHide id=h01>Heading Line 1 </span></TD>
</TR>

into this:

<TR>
<TD>
<span class='x1'><span class=PageHeadingHide</span>
<span class='x1'> id=h01>Heading Line 1 </span>
<span class='x1'></span></span>
</TD>
</TR>

It turns each piece of a Heading line into a separate span.

I don't really like using HTMLCSS so I usually avoid it. Try setting classes to the different elements of the report that you wish to style differently than what can be achieved in the WebFOCUS stylesheet.

DEFINE FILE CAR
TIMG/A150 = '<img id="imgToggle" src="/approot/baseapp/images/1.gif " ' |
            'width="9" height="9" onClick="fnToggle()" style="display: inline;">';
TSPAN1/A50 = '<span class=PageHeadingHide';
TSPAN2/A20 = '</span>';
END

TABLE FILE CAR
SUM
SALES
BY COUNTRY
ON TABLE HOLD AS H001 FORMAT HTMTABLE

HEADING
"<TIMG"
"<TSPAN1 id=h01>Heading Line 1 <TSPAN2"
"<TSPAN1 id=h02>Heading Line 2 <TSPAN2"

ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
TYPE=DATA, CLASS=ZeroData, WHEN= SALES LE 0, $
END
-RUN

-HTMLFORM BEGIN
<script language="JavaScript">

function fnToggle()
{

if (h01.className == 'PageHeadingHide')
  {
  imgToggle.src = "/approot/baseapp/images/0.gif";
  var spans = getElementsByClassName('PageHeadingHide');
  for(i=0; i <spans.length; i++)
    {
    spans[i].className = 'PageHeadingShow';
    }
  }
else
  {
  imgToggle.src = "/approot/baseapp/images/0.gif";
  var spans = getElementsByClassName('PageHeadingShow');
  for(i=0; i <spans.length; i++)
    {
    spans[i].className = 'PageHeadingHide';
    }
  }
}

function getElementsByClassName(className)
{
var all = document.all ? document.all : document.getElementsByTagName('*');
var elements = new Array();
for (var e = 0; e < all.length; e++)
  {
  if (all[e].className == className) elements[elements.length] = all[e];
  }
return elements;
}

</script>
<style type="text/css">
body { font-family: font-family: Arial, sans-serif; font-size: 12px; font-weight: normal; }
td { font-size: 12px; }

.ZeroData { color: red; }

.PageHeadingHide { display: none; }
.PageHeadingShow { display: inline; font-size: 14px; font-weight: bold; color: navy; }

</style>

!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