Format Example

This example shows you how to do group formatting.

Smartsite SXML CopyCode image Copy Code
<se:xmldatatable save="menu" resulttype="datatable">
    <se:row><se:col name="FoodType">Drinks</se:col><se:col name="Name">Coke</se:col><se:col name="Price" datatype="float">1.80</se:col></se:row>
    <se:row><se:col>Drinks</se:col><se:col>Coke</se:col><se:col>1.80</se:col></se:row>
    <se:row><se:col>Drinks</se:col><se:col>Water</se:col><se:col>0.80</se:col></se:row>
    <se:row><se:col>Drinks</se:col><se:col>Beer</se:col><se:col>2.50</se:col></se:row>
    <se:row><se:col>Drinks</se:col><se:col>Large beer</se:col><se:col>3.50</se:col></se:row>
    <se:row><se:col>Drinks</se:col><se:col>Wine</se:col><se:col>4.50</se:col></se:row>

    <se:row><se:col>Pizzas</se:col><se:col>Pizza Margarita</se:col><se:col>6.70</se:col></se:row>
    <se:row><se:col>Pizzas</se:col><se:col>Pizza Hawaii</se:col><se:col>8.20</se:col></se:row>
    <se:row><se:col>Pizzas</se:col><se:col>Quattro Stagioni</se:col><se:col>8.50</se:col></se:row>
    <se:row><se:col>Pizzas</se:col><se:col>Pizza Calzone</se:col><se:col>8.40</se:col></se:row>
    <se:row><se:col>Pizzas</se:col><se:col>Pizza Mare</se:col><se:col>11.00</se:col></se:row>

    <se:row><se:col>Desert</se:col><se:col>Espresso</se:col><se:col>3.50</se:col></se:row>
    <se:row><se:col>Desert</se:col><se:col>Irish coffee</se:col><se:col>4.50</se:col></se:row>
    <se:row><se:col>Desert</se:col><se:col>Dame blanche</se:col><se:col>3.50</se:col></se:row>
    <se:row><se:col>Desert</se:col><se:col>Tiramisu</se:col><se:col>5.00</se:col></se:row>
    
</se:xmldatatable>

<se:format inputdata="menu">
    <se:rowformat trim="right">
        {this.grouprownumber()}. {this.field(Name)} (Price: {this.field(price)})<br />
    </se:rowformat>
    
    <se:groupformat groupby="this.field(FoodType)">
        <h1>{this.groupnumber()}. {this.group()}</h1>
        {this.groupresult()}
    </se:groupformat>
    
</se:format>
Example Result CopyCode image Copy Code
<h1>1. Drinks</h1>
        
        1. Coke (Price: 1.8)<br />
        2. Coke (Price: 1.8)<br />
        3. Water (Price: 0.8)<br />
        4. Beer (Price: 2.5)<br />
        5. Large beer (Price: 3.5)<br />
        6. Wine (Price: 4.5)<br />
    
        <h1>2. Pizzas</h1>
        
        1. Pizza Margarita (Price: 6.7)<br />
        2. Pizza Hawaii (Price: 8.2)<br />
        3. Quattro Stagioni (Price: 8.5)<br />
        4. Pizza Calzone (Price: 8.4)<br />
        5. Pizza Mare (Price: 11)<br />
    
        <h1>3. Desert</h1>
        
        1. Espresso (Price: 3.5)<br />
        2. Irish coffee (Price: 4.5)<br />
        3. Dame blanche (Price: 3.5)<br />
        4. Tiramisu (Price: 5)<br />