GXT如何在XTemplate中显示树对象?

问题描述 投票:0回答:1

我有以下问题:我正在rever复杂的XTemplate中显示我的GXT项目的数据。

@XTemplate(source = "DepictionDisplay.html")
    SafeHtml displayoben(String shortName, String inventoryNumber, String cave, String wall, String expedition, String vendor, String purchaseDate, String currentLocation, String stateOfPreservation, SafeUri imageUri, SafeUri fullImageUri,
            SafeUri realCaveSketchUri, double width, double height, String style, String modeOfRepresentation, String description, String generalRemarks, String otherSuggestedIdentifications); 

DepictionDisplay.html的相关部分是:

            <table class="data-view">
                <tpl if="inventoryNumber != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Inventory No.</i></td>
                        <td class="data-view-right">{inventoryNumber}</td>
                </tr>
                </tpl>
                <tpl if="cave != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Located in Cave</i></td>
                        <td class="data-view-right">{cave}</td>

                </tr>
                </tpl>
                <tpl if="wall != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Position in cave</i></td>
                        <td class="data-view-right">{wall}</td>
                </tr>
                </tpl>
                <tpl if="expedition != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Acquired by expedition</i></td>
                        <td class="data-view-right">{expedition}</td>
                </tr>
                </tpl>
                <tpl if="vendor != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Vendor</i></td>
                        <td class="data-view-right">{vendor}</td>
                </tr>
                </tpl>
                <tpl if="purchaseDate != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Purchase Date</i></td>
                        <td class="data-view-right">{purchaseDate}</td>
                </tr>
                </tpl>
                <tpl if="currentLocation != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Current location</i></td>
                        <td class="data-view-right">{currentLocation}</td>
                </tr>
                </tpl>
                <tpl if="stateOfPreservation != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>State of preservation</i></td>
                        <td class="data-view-right">{stateOfPreservation}</td>
                </tr>
                </tpl>
                <tpl if="style != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Style</i></td>
                        <td class="data-view-right">{style}</td>
                </tr>
                </tpl>
                <tpl if="modeOfRepresentation != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Mode of representation</i></td>
                        <td class="data-view-right">{modeOfRepresentation}</td>
                </tr>
                </tpl>
        </table>

问题是,最近,我不得不将以前的wall的String值更改为树对象。树对象的条目具有用于向下导航的getchildren()函数和用于访问要显示的String值的getText()函数。

我的问题现在是:如何在此表中显示树对象?到目前为止,我找不到合适的选项,因为树的深度可能会有所变化。

任何想法都会受到赞赏。

真诚地,

Erik

java gwt gxt
1个回答
0
投票

XTemplates可以采用SafeHtml参数,并插入该内容,并支持调用简单的格式化函数,但不能递归调用自身或其他函数。

考虑迭代该getChildren(),并将其每个呈现的模板附加到SafeHtmlBuilder,然后将生成的SafeHtml字符串传递给父级。然后,您自己的代码进行递归,将较小的内容插入较大的内容。

© www.soinside.com 2019 - 2024. All rights reserved.