Chapter II. Advanced Integration
Prev | 13. Configuring the Table Autoformat Feature | Next

## 13. Configuring the Table Autoformat Feature

Using the table autoformat feature, you can insert a table with a predefined layout or apply a predefined format to an exisiting table.

When inserting a new table using the "Insert Table" dialog, you can select a table template by pressing the "AutoFormat..." button at the bottom of the dialog. This in turn opens the "Table Auto Format" dialog, which lets you select a table template to insert.

Alternatively, you can add the `TABLEAUTOFORMAT` action to your user interface and call this action when inside a table. This will let you select and apply a template to the current table. For details about the user interace configuration, see Adjusting the User Interface.

A number of default templates are included with the editor by default. These templates are all pre-configured in the sample config.xml included within the edit-on Pro installation package.

If you do not want one or any of these templates to be available in the dialog, simply remove them from the configuration.

Example configuration:

    <tableautoformat>
        <!-- default templates -->
        <tableautoformattemplateurl url="templates/classic1.xml" />
        <tableautoformattemplateurl url="templates/classic2.xml" />
        <tableautoformattemplateurl url="templates/classic3.xml" />
        <tableautoformattemplateurl url="templates/classic4.xml" />
        <tableautoformattemplateurl url="templates/color1.xml" />
        <tableautoformattemplateurl url="templates/color2.xml" />
        <tableautoformattemplateurl url="templates/color3.xml" />
        <tableautoformattemplateurl url="templates/column1.xml" />
        <tableautoformattemplateurl url="templates/column2.xml" />
        <tableautoformattemplateurl url="templates/column3.xml" />
        <tableautoformattemplateurl url="templates/contemp.xml" />
        <tableautoformattemplateurl url="templates/normal.xml" />
        <tableautoformattemplateurl url="templates/simple1.xml" />
        <tableautoformattemplateurl url="templates/simple2.xml" />
        <tableautoformattemplateurl url="templates/simple3.xml" />
    </tableautoformat>

The default templates are all located within the edit-on Pro JAR file. You can of course specify a custom template by adding a `tableautoformattemplateurl` entry to the list of table templates and specifying the URL of the template. The URL may be relative to the editor code base.

Example configuration without any default templates and a single custom template:

    <tableautɯformat>
        <tableautoformattemplateurl url="http://server/template.xml" />
    </tableautoformat>

The template itself is an XML file which specifies the structure of the table template. Example template file:

    <tableautoformattemplate>
        <template  name="simple1">
        <wholetable>
           <attribute name="cellspacing" value="0"/>
           <attribute name="cellpadding" value="0"/>
           <attribute name="border" value="1"/>
        </wholetable>
        <topleftcell>
           <attribute name="style"
           value="border:0.75pt solid  green;"/>
        </topleftcell>
        <leftcolumn>
           <attribute name="style"
           value="border-style:none;"/>
        </leftcolumn>
        <firstrow>
           <attribute name="style"
           value="border:0.75pt solid  green;"/>
        </firstrow>
        <rightcolumn>
           <attribute name="style"
           value="border-style:none;"/>
        </rightcolumn>
        <lastrow>
           <attribute name="style"
           value="border:0.75pt solid green;"/>
        </lastrow>
        <evenrowstripes>
           <attribute name="style"
           value="border-style:none;"/>
        </evenrowstripes>
        <bottomleftcell>
           <attribute name="style"
           value="border:none;"/>
        </bottomleftcell>
        <toprightcell>
           <attribute name="style"
           value="border-bottom:0.75pt solid green;"/>
        </toprightcell>
        <bottomrightcell>
           <attribute name="style"
           value=""/>
        </bottomrightcell>
        <oddrowstripes>
           <attribute name="style"
           value="border-style:none;"/>
        </oddrowstripes>
      </template>
      </tableautoformattemplate>

In addition to being defined in separate files, table templates may also be defined directly within the config.xml. Example table autoformat configuration with all default templates being enabled, a custom template loaded from an external URI and a custom template defined directly:

    <tableautoformat>
        <!-- default templates -->
        <tableautoformattemplateurl url="templates/classic1.xml" />
        <tableautoformattemplateurl url="templates/classic2.xml" />
        <tableautoformattemplateurl url="templates/classic3.xml" />
        <tableautoformattemplateurl url="templates/classic4.xml" />
        <tableautoformattemplateurl url="templates/color1.xml" />
        <tableautoformattemplateurl url="templates/color2.xml" />
        <tableautoformattemplateurl url="templates/color3.xml" />
        <tableautoformattemplateurl url="templates/column1.xml" />
        <tableautoformattemplateurl url="templates/column2.xml" />
        <tableautoformattemplateurl url="templates/column3.xml" />
        <tableautoformattemplateurl url="templates/contemp.xml" />
        <tableautoformattemplateurl url="templates/normal.xml" />
        <tableautoformattemplateurl url="templates/simple1.xml" />
        <tableautoformattemplateurl url="templates/simple2.xml" />
        <tableautoformattemplateurl url="templates/simple3.xml" />
        <tableautoformattemplateurl url="http://server/tabtemplate.xml"/>
        <!-- custom templates -->
        <tableautoformattemplateurl url="http://server/template.xml" />
        <!-- custom template directly defined in the config -->
        <tableautoformattemplate >
            <template name="direct">
                <wholetable>
                    <attribute name="cellspacing" value="0"/>
                    <attribute name="cellpadding" value="0"/>
                    <attribute name="border" value="6"/>
                </wholetable>
                <topleftcell>
                    <attribute name="style"
                    value="border:0.75pt solid black;"/>
                </topleftcell>
                <leftcolumn>
                    <attribute name="style"
                    value="border:none;background-color:white;"/>
                </leftcolumn>
                <firstrow>
                    <attribute name="style"
                    value="border:0.75pt solid black;"/>
                </firstrow>
                <rightcolumn>
                    <attribute name="style"
                    value="border-style:none;color:black;background-color:white;"/>
                </rightcolumn>
                <lastrow>
                    <attribute name="style"
                    value="border:0.75pt solid black;"/>
                </lastrow>
                <evenrowstripes>
                    <attribute name="style"
                    value="border-style:none;color:black;background-color:white;"/>
                </evenrowstripes>
                <bottomleftcell>
                    <attribute name="style"
                    value="border:0.75pt solid black;font-weight:bold;"/>
                </bottomleftcell>
                <toprightcell>
                    <attribute name="style"
                    value="border:none;font-weight:bold;"/>
                </toprightcell>
                <bottomrightcell>
                    <attribute name="style"
                    value=""/>
                </bottomrightcell>
                <oddrowstripes>
                    <attribute name="style"
                    value="color:black;border-style:none;background-color:white;"/>
                </oddrowstripes>
            </template>
        </tableautoformattemplate>
    </tableautoformat>

Prev | Up | Next
12. Event Handlers | Home | 14. Preloading the Applet and JVM