Title: word box runtime Post by: Jose Edvandro M. on June 01, 2022, 06:52:19 pm I need to dynamically create columns in the report as per the selection on the screen.
I have a segment field (integer) with possible values from 1 to 12 (referring to the months of the year). Example: I have the month March 2021 selected. Then I would create the columns: JAN/2021 FEB/2021 MAR/2021, I would create these columns with the titles. and on oneveryrow would feed the fields Ex: JAN/2021 FEB/2021 MAR/2021 - Title 1250,00 0,00 570,00 - oneveryrow 380,00 1,20 954,00 REPORT ctb0171x_ccusto_4rp - new function REPORT ctb0171x_ccusto - old function Title: Re: word box runtime Post by: Alex G. on June 01, 2022, 08:33:07 pm Hi Jose,
There is the sample report DynamicColumnsTable.4rp which demonstrates a possible technique. I quickly creates a simpler version for you just now. I have this 4gl: $cat Jose.4gl: IMPORT FGL greruntime CONSTANT NUMBER_OF_COLUMNS=3 CONSTANT NUMBER_OF_ROWS=6 MAIN DEFINE saxHandler om.SaxDocumentHandler, row,col INTEGER, value DECIMAL(10,2) IF NOT fgl_report_loadCurrentSettings("Jose.4rp") THEN EXIT PROGRAM END IF CALL fgl_report_selectDevice(getPreviewDevice()) LET saxHandler=fgl_report_commitCurrentSettings() START REPORT DynamicColumnReport TO XML HANDLER saxHandler FOR row = 1 TO NUMBER_OF_ROWS FOR col = 1 TO NUMBER_OF_COLUMNS OUTPUT TO REPORT DynamicColumnReport(NUMBER_OF_COLUMNS,row,col,row*123+col*456) END FOR END FOR FINISH REPORT DynamicColumnReport END MAIN REPORT DynamicColumnReport(numberOfColumns,row,col,value) DEFINE numberOfColumns,row,col,titleColumn INTEGER, value DECIMAL(10,2) ORDER EXTERNAL BY numberOfColumns,row FORMAT BEFORE GROUP OF numberOfColumns FOR titleColumn = 1 TO numberOfColumns PRINT titleColumn END FOR ON EVERY ROW PRINT row,col,value END REPORT FUNCTION getPreviewDevice() DEFINE fename String CALL ui.interface.frontcall("standard", "feinfo", ["fename"],[fename]) RETURN iif(fename=="Genero Desktop Client","SVG","PDF") END FUNCTION and this design: $cat Jose.4rp: <?xml version="1.0" encoding="UTF-8"?> <report:Report xmlns:rtl="http://www.4js.com/2004/RTL" xmlns:report="http://www.4js.com/2007/REPORT" xmlns="http://www.4js.com/2004/PXML" gstVersion="40a00" version="7.00"> <report:Settings RWPageWidth="letterwidth" RWPageLength="letterlength" RWLeftMargin="0.5inch" RWTopMargin="0.5inch" RWRightMargin="0.5inch" RWBottomMargin="0.5inch"> <report:FormatList> <report:Format-SVG/> <report:Format-PDF/> <report:Format-image/> </report:FormatList> </report:Settings> <report:Data RWDataLocation="Jose.rdd" RWFglReportName="DynamicColumnReport"/> <report:Conflicts/> <rtl:stylesheet> <PXML> <rtl:match name="Report" nameConstraint="Report" minOccurs="1" maxOccurs="1"> <rtl:match name="Group numberOfColumns" nameConstraint="Group" minOccurs="0" maxOccurs="unbounded"> <MINIPAGE name="Page Root" width="max" length="max"> <LAYOUTNODE name="Page Header" width="max" length="min" port="anyPageHeader"> <MINIPAGE name="StripeLayouter3" width="min" length="max" layoutDirection="leftToRight"> <WORDBOX name="Report Title" x="0" y="max/2" anchorX="0" anchorY="0.5" alignment="baseline" fontSize="25" baselineType="leftleft" floatingBehavior="enclosed" text="Report Title Here"/> <PAGENOBOX name="PageNoBox" x="1.23857" y="max" anchorX="0" anchorY="1" alignment="baseline" baselineType="leftleft" floatingBehavior="enclosed" textAlignment="right"/> </MINIPAGE> <MINIPAGE name="Table Header" class="grwTableHeader" width="min" length="max" layoutDirection="leftToRight"> <WORDBOX name="Spacer" alignment="baseline" baselineType="leftleft" port="itemSeparator" text=" "/> <rtl:match name="BeforeGroup numberOfColumns" nameConstraint="BeforeGroup" minOccurs="1" maxOccurs="1"> <rtl:match name="For" nameConstraint="For" minOccurs="1" maxOccurs="1"> <rtl:match name="ForItem" nameConstraint="ForItem" minOccurs="0" maxOccurs="unbounded"> <WORDBOX name="titleColumn Title" designHints="fieldName:titleColumn;fieldRole:TableColumnTitle" class="grwTableNumericColumnTitle" width="{max(width("{"TitleColumn".translate()}"),width("-0000000000"))}" floatingBehavior="enclosed" textAlignment="right" text="TitleColumn" localizeText="true"/> </rtl:match> </rtl:match> </rtl:match> </MINIPAGE> <MINIPAGE name="Separator" width="1" length="max" bgColor="#000000" layoutDirection="leftToRight"/> </LAYOUTNODE> <rtl:match name="Group row" nameConstraint="Group" minOccurs="0" maxOccurs="unbounded"> <MINIPAGE name="Table Row" class="grwTableRow" width="min" length="max" layoutDirection="leftToRight"> <WORDBOX name="Spacer_1" alignment="baseline" baselineType="leftleft" port="itemSeparator" text=" "/> <rtl:match name="OnEveryRow" nameConstraint="OnEveryRow" minOccurs="0" maxOccurs="unbounded"> <rtl:input-variable name="value" type="FGLNumeric" expectedLocation="expectedHere"/> <DECIMALFORMATBOX name="value Value" designHints="fieldName:value;fieldRole:TableColumnValue" class="grwTableNumericColumnValue" width="{max(width("{"Value".translate()}"),width("-00,000,000.00"))}" anchorX="1" floatingBehavior="enclosed" textAlignment="right" format="--,---,--&.&&" value="{{value}}"/> </rtl:match> </MINIPAGE> </rtl:match> </MINIPAGE> </rtl:match> </rtl:match> </PXML> </rtl:stylesheet> </report:Report> I hope that this works as a starting point. Title: Re: word box runtime Post by: Jose Edvandro M. on June 01, 2022, 09:10:19 pm thanks
|