[SOLVED] Truncate and drill down based on field character length
I am looking for ideas on how to do this:
I have a report that contains a 'Notes' field. The notes field can be quite lengthy some times and I would like to truncate it at 300 characters.
In cases where the field is less than 300 characters it will display the full note.
In cases where the field is more than 300 characters it will be cut off, but I would like to add the word "more..." at the end of the data so that a user can click on the word 'more...' drill down to see the full note in a new window.
I am thinking I can do a defined field that truncates at 300 characters, then a defined field that is simply the text "more...", then have a 'when' statement to add a column for the text "more..." if characters exceed 300.
Any ideas on how to approach this? Thanks in advance.This message has been edited. Last edited by: LDW,
7.6.8 Windows xp html
June 11, 2009, 02:54 PM
Francis Mariani
Here's one idea, instead of a drill-down, use JavaScript to hide/show an extra row when the data is longer than a given length. This is a working example that displays a + image if the MODEL length is greater than 12. Click on the + and the full MODEL is displayed in a new row.
-*-- Hide and Show TDs to demonstrate displaying extra data for a cell on a report
-SET &ECHO=ALL;
SET HOLDLIST = PRINTONLY
SET ASNAMES = ON
SET HOLDFORMAT = ALPHA
SET PAGE = NOLEAD
-RUN
TABLE FILE CAR
PRINT
COUNTRY
CAR
MODEL
DEALER_COST
RETAIL_COST
SALES
COMPUTE COUNTER/I4 = COUNTER + 1;
BY COUNTRY NOPRINT
BY CAR NOPRINT
BY MODEL NOPRINT
ON TABLE HOLD AS H001
END
-RUN
DEFINE FILE H001
MODEL_SMALL/A10 = SUBSTR(25, MODEL, 1, 12, 12, 'A10');
LINK_OPEN/A200 = IF ARGLEN(24, MODEL, 'I4') LE 12 THEN MODEL ELSE
MODEL_SMALL || '&|nbsp;&|nbsp;<img id="idImg' || EDIT(COUNTER) ||
'" src="/approot/baseapp/1.gif" width="9" height="9"' ||
' onClick="fnToggle(''' || EDIT(COUNTER) || ''')">';
MODEL_EXTRA/A999 = IF ARGLEN(24, MODEL, 'I4') LE 12 THEN '' ELSE
'</TD><tr><td colspan=2></td><td colspan=4 id="idTD' || EDIT(COUNTER) || '" style="display: ''none'';">' ||
MODEL || '</td></tr>';
END
-RUN
TABLE FILE H001
PRINT
COUNTRY AS 'Country'
CAR AS 'Car'
LINK_OPEN AS 'Model'
DEALER_COST AS 'Dealer,Cost'
RETAIL_COST AS 'Retail,Cost'
SALES AS 'Sales'
MODEL_EXTRA AS ''
BY COUNTRY NOPRINT
BY CAR NOPRINT
BY MODEL NOPRINT
ON COUNTRY SUBFOOT
" "
HEADING CENTER
"Car Sales"
" "
ON TABLE HOLD AS H002 FORMAT HTMTABLE
ON TABLE SET STYLE *
TYPE=REPORT, GRID=OFF, SQUEEZE=ON, $
TYPE=HEADING, STYLE=BOLD, $
TYPE=TITLE, STYLE=BOLD, COLOR=NAVY, $
ENDSTYLE
END
-RUN
-IF &FOCERRNUM NE 0 GOTO FOC_ERROR;
-SET &ECHO=OFF;
-HTMLFORM BEGIN
<html>
<head>
<title>Car Test</title>
<style type="text/css">
BODY { font-family: Arial, sans-serif; font-size: 10pt; }
TD { font-size: 10pt; }
U {text-decoration: none;}
</style>
<script language="JavaScript">
function fnToggle(vCounter)
{
vTD = eval("idTD" + vCounter);
vImg = eval("idImg" + vCounter);
if (vTD.style.display == 'none')
{
vTD.style.display = '';
vImg.src = "/approot/baseapp/0.gif";
}
else
{
vTD.style.display = 'none';
vImg.src = "/approot/baseapp/1.gif";
}
}
</script>
</head>
<body>
<center>
!IBI.FIL.H002;
</center>
</body>
</html>
-HTMLFORM END
-EXIT
You will need these two images, rename then to 0.gif and 1.gif and put them in your baseapp folder:
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
June 12, 2009, 08:54 AM
LDW
Thanks Francis. I like this idea better than the one I was thinking. I will give it a try.