ViewHierarchy from XmlDataTable Example

In this example the parent-child relation used by ViewHierarchy is based on the relation between parent and key fields. Nesting is made visible by indenting the children of each row.

Smartsite SXML CopyCode image Copy Code
<se:xmldatatable>
    <se:parameters>
        <se:parameter name="resulttype">datatable</se:parameter>
        <se:parameter name="save">data</se:parameter>
        <se:parameter name="xml">
            <se:row>
                <se:col name="key" datatype="string">root</se:col>
            </se:row>
            <se:row>
                <se:col>Science</se:col>
                <se:col name="parent" datatype="string">root</se:col>
            </se:row>
            <se:row>
                <se:col>Music</se:col>
                <se:col>root</se:col>
            </se:row>
            <se:row>
                <se:col>Physics</se:col>
                <se:col>Science</se:col>
            </se:row>
            <se:row>
                <se:col>Chemistry</se:col>
                <se:col>Science</se:col>
            </se:row>
            <se:row>
                <se:col>Astrophysics</se:col>
                <se:col>Physics</se:col>
            </se:row>
            <se:row>
                <se:col>Quantum Chromo Dynamics</se:col>
                <se:col>Physics</se:col>
            </se:row>
            <se:row>
                <se:col>Metal</se:col>
                <se:col>Music</se:col>
            </se:row>
            <se:row>
                <se:col>Rock</se:col>
                <se:col>Music</se:col>
            </se:row>
            <se:row>
                <se:col>Jazz</se:col>
                <se:col>Music</se:col>
            </se:row>
        </se:parameter>
    </se:parameters>
</se:xmldatatable>
<se:viewhierarchy>
    <se:parameters>
        <se:parameter name="inputdata">data</se:parameter>
        <se:parameter name="keyfield">key</se:parameter>
        <se:parameter name="parentfield">parent</se:parameter>
        <se:parameter name="format">
            <se:rowformat>{string.repeat(char.tab(), this.field(level))}{this.field(key)}</se:rowformat>
            <se:rowdelimiter>{char.crlf()}</se:rowdelimiter>
        </se:parameter>
    </se:parameters>
</se:viewhierarchy>
Example Result CopyCode image Copy Code
Science
        Physics
            Astrophysics
            Quantum Chromo Dynamics
        Chemistry
    Music
        Metal
        Rock
        Jazz