Focal Point
Accordion report
February 27, 2007, 01:24 PM
FrankDutchAccordion report
I want to build an accordion report
TABLE FILE CAR
SUM SALES
BY COUNTRY
BY MODEL
BY TYPE
BY CAR
ON TABLE SET EXPANDABLE ON
END
But I would like the result of the accordion not on all the by fields but only ad the last one, so the report starts with the opened by fields up to the type.
Will that be possible?
Frank
|
Frank |
| prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7 |
February 28, 2007, 08:36 AM
Alan BFrank
I have an idea about this, I did something similar to what you required a few years ago using javascript. If you are interested in this I can get something together in a day or so. Let me know if this would be of interest, I don't want to spend the time if this approach would not be acceptable.
Alan.
WF 7.705/8.007
February 28, 2007, 09:25 AM
WFLurkerI was about to ask the same question.
Is Javascript the only way to be able to do that?
WF 8105M
- Portal, Dashboard
- Rcaster, Data Migrator
- Windows 2012 Client Server
- Dev/App Studio 8105
- Data: SQL, Oracle, Neteeza,MVS
February 28, 2007, 09:28 AM
FrankDutchIt's sound great, but let me first put this question to the IBI helpdesk, since your solution would be a work around while I believe this should be part of the functionality it self
(It will be in the next version, a typical software engenering answer!)
|
Frank |
| prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7 |
February 28, 2007, 09:28 AM
Alan BI believe javascript is the only way, MHO. The way an accordion report works adds a little spice to the javascript processing.
Alan.
WF 7.705/8.007
February 28, 2007, 09:54 AM
FrankDutchI'm sure you are right about the javascript.
if you look in the source from a accrodion report (the generated HTML) you see a lot of javascripting.
it must be something there....
|
Frank |
| prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7 |
February 28, 2007, 01:50 PM
Tony AYou can actually achieve this fairly simply but I must admit that the code doesn't sit right from a well formed code point of view
This works in IE 7 -
TABLE FILE CAR
SUM RCOST
DCOST
BY COUNTRY
BY CAR
BY MODEL
ON TABLE SET EXPANDABLE ON
END
-RUN
-HTMLFORM BEGIN
<script>
toggle("table1","by_1");
toggle("table1","by_2");
toggle("table1","by_3");
toggle("table1","by_4");
toggle("table1","by_5");
</script>
-HTMLFORM END
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 | |
February 28, 2007, 01:55 PM
FrankDutchthanks Tony, that looks simply I will give it a try (tomorrow) and will let you know if this works on IE 5 or 6
|
Frank |
| prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7 |
February 28, 2007, 02:05 PM
Alan BTony
This would not work in real life. The by_1, by_2 etc. reference is only for the first sort column, and you don't know how many rows there are. For the second sort column, you have to work within each outer sort and so on.
This is what I meant earlier. You have to traverse the TABLE with javascript from top to bottom and find out what needs to be expanded. Whilst do-able, it is rather more complicated than this.
Alan.
WF 7.705/8.007
February 28, 2007, 02:18 PM
Tony AAlan,
Agreed, but then it was only meant to give the idea on what must be actioned in javascript to expand the items. You know and I know that this should be a simple case of seeing what the anchor tag holds to action the expansion but those who are not confident in using or writing javascript will often baulk at the idea.
And, yes, using Javascript to search through the DOM (document object model for those not familiar) and work out what needs expanding, is probably beyond most. However, again as you know and I know, there is always a way in FOCUS (or most times anyway), so -
TABLE FILE CAR
SUM COMPUTE FstBY/I1 = IF COUNTRY NE LAST COUNTRY THEN LAST FstBY + 1 ELSE LAST FstBY; NOPRINT
COMPUTE Script1/A40 = 'toggle("table1","by_'||EDIT(FstBY)||'");';
BY COUNTRY NOPRINT
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS HOLD1
END
-RUN
TABLE FILE CAR
SUM COMPUTE FstBY/I1 = IF COUNTRY NE LAST COUNTRY THEN LAST FstBY + 1 ELSE LAST FstBY; NOPRINT
COMPUTE ScnBY/I1 = IF COUNTRY NE LAST COUNTRY THEN 1
ELSE IF CAR NE LAST CAR THEN LAST ScnBY + 1 ELSE LAST ScnBY; NOPRINT
COMPUTE Script2/A40 = 'toggle("table1","by_'||EDIT(FstBY)||'_'||EDIT(ScnBY)||'");';
BY COUNTRY NOPRINT
BY CAR NOPRINT
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS HOLD2
END
-RUN
TABLE FILE CAR
SUM RCOST
DCOST
BY COUNTRY
BY CAR
BY TYPE
BY MODEL
ON TABLE SET EXPANDABLE ON
END
-RUN
-SET &ECHO = ALL;
-HTMLFORM BEGIN
<script>
!IBI.FIL.HOLD1;
!IBI.FIL.HOLD2;
</script>
-HTMLFORM END
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 | |
February 28, 2007, 02:28 PM
Alan BIndeed. An approach like that could work.
I find this an interesting exercise, because there will be many different approaches using FOCUS. I would perhaps, use a record count within each sort and build the js up in a DM repeat loop.
I did manage to find the js I used to rearrange the data in a FOCUS table previously. Maybe, just maybe, this could be utilised for a generic approach. I'm mulling it over tonight.
Alan.
WF 7.705/8.007
February 28, 2007, 05:23 PM
FrankDutchIt would however be great to be able to set something like
ON TABLE SET EXPANDABLE ON COUNTRY MODEL
to make only country and model expandable....
next version perhaps?..
|
Frank |
| prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7 |
March 01, 2007, 03:25 AM
Alan BIt's little things like this
ON TABLE SET EXPANDABLE ON COUNTRY MODEL
that make up such a rich language for us to use. It would be good. Would it be so difficult to implement?
I like this idea because an accordion report looks so 'nothing' on the page, there is no immediate impact for the user, just a menu looking item, which once they start to expand will make much more sense.
Back to reality, and I was surprised on looking at the output of an accordion report how accessible it is to javascript. I took me only a few minutes to get a javascript to expand any number of columns and should work across the board.
In a file I've called expand.js
function expandColumns(){
var i=0;var s='';var t='';var u='';
// Get an array of all the td tags in the document.
var allTD = document.getElementsByTagName("td");
// How many td tags are there
var numTD = allTD.length;
// Loop through all the td tags
for (i=0;i<numTD-1;++i) {
// First of 3 checks - if the td tag doesn't have an image, go to next iteration
if (allTD[i].getElementsByTagName("img").length == 0) continue;
// Second of 3 checks - if there is no attribute called ibiattr in the td, go to next iteration
if (allTD[i].getAttribute("ibiattr") == 0) continue;
// Third of 3 checks - if the attribute called ibiattrc in the td has a value greater than the
// column to expand, go to next iteration
if (allTD[i].getAttribute("ibiattrc") > columnsToExpand) continue;
// get the a tag within the td
s=allTD[i].getElementsByTagName("a");
// get the href within the a tag
t=s[0].getAttribute("href");
// substring the href to get the call to the function (remove the 'javascript:')
u=t.substring(11,t.length);
// call the function
eval(u)
}
}
in your focexec add
DEFINE FILE fn
callJS/A140 = '<script src="path/expand.js" type="text/javascript"></script>' |
'<script>window.onload=expandColumns;var columnsToExpand=2;</script>';
END
TABLE FILE fn
ON TABLE SUBFOOT
"<callJS"
.
.
Where columnsToExpand is the number of columns to expand on opening the report.
(Much as I like and use Firefox, the accordion report has brought out a very nasty bug in it!)
Alan.
WF 7.705/8.007
March 02, 2007, 02:50 AM
Alan BSmall addition to the js file for the accordion report. If you want to stop the user unexpanding(!) the open columns and to overcome the Firefox bug, you can add:
.
.
eval(u)
allTD[i].removeChild(s[0]);
}
if(navigator.userAgent.indexOf("Firefox") != -1)
document.getElementsByTagName("table")[0].style.borderCollapse="separate";
}
Alan.
WF 7.705/8.007