Advanced Row Formatting - ColFormat

Release 1.0 - ...

In some cases, the site builder does not know in advance which column will be available in the datatable output of a macro. In these cases you can use the colformat. If a rowformat contains a colformat, it will apply this colformat to every column in the datatable. If multiple colformat elements are given, they will be matched based on their match and expression attribute, just like the rowformats.

Example 1:

Smartsite SXML CopyCode image Copy Code
<se:sqlquery sql="select top 10 Nr, Name from FileTypes order by Nr">
    <se:parameters>
        <se:parameter name="format">      
            <se:rowformat>
                <se:colformat trim="right">
                        <td>{this.field()}</td>
                </se:colformat>
                <se:rowresult trim="right">
                    <tr>{this.rowresult()}
                    </tr>
                </se:rowresult>
            </se:rowformat>
        </se:parameter>
        <se:parameter name="resultformat">
            <table border="1">
                {this.result()}
            </table>
        </se:parameter>
    </se:parameters>
</se:sqlquery>

Now suppose you want to have 2 rowformat with multiple colformat but there is a colformat that is the same in both rowformat. In that case you can move that common colformat outside a rowformat. These colformats are called global colformats. Global colformats are applied if no local colformat is applicable for the current row. This way you can create tables like this.

Example 2:

Smartsite SXML CopyCode image Copy Code
<se:sqlquery sql="select top 10 Nr, Name from FileTypes order by Nr">
    <se:parameters>
        <se:parameter name="format">
 
            <!-- This is the global colformat that will be applied is no other colformat is applicable -->
            <se:colformat trim="right">
                    <td>{this.field()}</td>
            </se:colformat>
 
            <!-- This rowformat will be applied to the first row -->
            <se:rowformat match="first">
                <se:colformat trim="right">
                    <td style="background-color: DeepSkyBlue">{this.field()}</td>
                </se:colformat>
                <se:rowresult trim="right">
                <tr>
                        {this.rowresult()}
                </tr>
                </se:rowresult>
            </se:rowformat>
 
            <!-- This rowformat will be applied to all the other rows -->
            <se:rowformat>
                <se:colformat match="first" trim="right">
                    <td style="background-color: GainsBoro">{this.field()}</td>
                </se:colformat>
                <se:rowresult trim="right">
                <tr>
                        {this.rowresult()}
                </tr>
                </se:rowresult>
            </se:rowformat>
 
        </se:parameter>
    
        <se:parameter name="resultformat">
            <table border="1">
                {this.result()}
            </table>
        </se:parameter>
    </se:parameters>
</se:sqlquery>