how to make table rows adjust their height to the height of your table?

0

for example :  i have a table(MAIN) with 2 columns(FIRST,SECOND), each column has a table. if my second table has 10 rows, and my first table has 1 row, the table adjust their heights to each other. but i want the single row in my first table to occupy all the height of the table, instead i have 1 valued row and 9 empty rows. is there a way to solve this problem?

fahim.hasan's picture
Joined: Aug 29 2017 - 8:37am
Last seen: 2 years 3 months ago

1 Answer:

0

Check this jrxml. 

I have used the detail band and one table element to replicate what you were doing with 2 table elements.

The concept would be same. The initial table should be stretched to the band height.  

 

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="tablealignment" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f6dbae90-77f7-4f15-b929-2fb39c55987c">
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="Dataset1" uuid="14e0e132-36f8-4f16-8e64-12d231b45acf">
        <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="PRODSUP"/>
        <parameter name="ID" class="java.math.BigDecimal"/>
        <queryString language="SQL">
            <![CDATA[select * from ( 
select 1 as ID, 'Color1-1' as text from dual union all
select 1 as ID, 'Color1-2' as text from dual union all
select 1 as ID, 'Color1-3' as text from dual union all
select 2 as ID, 'Color2-1' as text from dual union all
select 3 as ID, 'Color3-1' as text from dual union all
select 3 as ID, 'Color3-2' as text from dual union all
select 3 as ID, 'Color3-3' as text from dual union all
select 3 as ID, 'Color3-4' as text from dual union all
select 3 as ID, 'Color3-5' as text from dual ) 
where ID  =  $P{ID} 
]]>
        </queryString>
        <field name="ID" class="java.math.BigDecimal"/>
        <field name="TEXT" class="java.lang.String"/>
    </subDataset>
    <queryString language="SQL">
        <![CDATA[select 1 as ID, 'One' as text from dual union all
select 2 as ID, 'Two' as text from dual union all
select 3 as ID, 'Three' as text from dual]]>
    </queryString>
    <field name="TEXT" class="java.lang.String"/>
    <field name="ID" class="java.math.BigDecimal"/>
    <group name="ID">
        <groupExpression><![CDATA[$F{ID}]]></groupExpression>
    </group>
    <background>
        <band splitType="Stretch"/>
    </background>
    <columnHeader>
        <band height="20" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="80" height="20" uuid="ab262d73-28fe-4290-9bb3-fd12f0cf277b"/>
                <text><![CDATA[Column Header]]></text>
            </staticText>
            <staticText>
                <reportElement x="80" y="0" width="100" height="20" uuid="8e7b84f5-2e38-4c87-8714-7c178f72e83b"/>
                <text><![CDATA[Table Header]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="20" splitType="Stretch">
            <textField>
                <reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="80" height="20" uuid="404e4662-e55c-4781-b306-22436e82f293"/>
                <box>
                    <pen lineWidth="1.0"/>
                </box>
                <textFieldExpression><![CDATA[$F{TEXT}]]></textFieldExpression>
            </textField>
            <componentElement>
                <reportElement x="80" y="0" width="100" height="20" uuid="0cdcdc65-ef96-4d7c-b660-5f53e2d1ec19">
                    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                    <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
                    <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
                    <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
                </reportElement>
                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                    <datasetRun subDataset="Dataset1" uuid="544c6f50-1f07-4684-9297-7b22e2a19e30">
                        <datasetParameter name="ID">
                            <datasetParameterExpression><![CDATA[$F{ID}]]></datasetParameterExpression>
                        </datasetParameter>
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:column width="100" uuid="bfcaa2cb-4b81-42d4-aea8-87c5cd753369">
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                        <jr:detailCell style="Table_TD" height="20">
                            <property name="com.jaspersoft.studio.unit.height" value="px"/>
                            <property name="com.jaspersoft.studio.unit.width" value="px"/>
                            <box>
                                <pen lineWidth="1.0"/>
                            </box>
                            <textField>
                                <reportElement x="0" y="0" width="100" height="20" uuid="c343f8cf-faef-472a-864d-d20dc4f8998b"/>
                                <textFieldExpression><![CDATA[$F{TEXT}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
</jasperReport>
 

reportdev's picture
1222
Joined: Oct 12 2015 - 12:05pm
Last seen: 2 weeks 4 days ago
Feedback
randomness