【问题标题】:How to make an item always appear last on list (Netsuite Advanced PDF)如何使项目始终显示在列表的最后(Netsuite 高级 PDF)
【发布时间】:2021-08-25 18:50:58
【问题描述】:

如果某项出现在发票中(高级 PDF、NetSuite)中,我正在尝试使该项目出现在列表的最后。

我正在考虑尝试排序并在项目名称中添加一些 ZZZ,但那是因为我对基本 HTML 之外的知识了解不多。

任何帮助将不胜感激。 下面是我正在处理的表格代码。

 <table class="itemtable" style="width: 100%; margin-top: 10px;"><!-- start items --><#list record.item as item><#if item_index==0>
<thead>
    <tr>
    <th align="center" colspan="3">${item.quantity@label}</th>
    <th colspan="12">${item.item@label}</th>
    <th colspan="3">${item.options@label}</th>
    <th align="right" colspan="4">${item.rate@label}</th>
    <th align="right" colspan="4">${item.amount@label}</th>
    </tr>
</thead>
</#if><tr>
    <td align="center" colspan="3" line-height="150%">${item.quantity}</td>
    <td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
    <td colspan="3">${item.options}</td>
    <td align="right" colspan="4">${item.rate}</td>
    <td align="right" colspan="4">${item.amount}</td>
    </tr>
    </#list>

我需要能够选择始终显示在底部的特定项目名称。

【问题讨论】:

    标签: netsuite freemarker


    【解决方案1】:

    您可以使用 assign 标签来保存底部项目的值。

    <#assign bottomItemName = 'Bottom Item Name'>
    <#assign bottomItem = {}>
    
    <#list record.item as item>
        <#if item_index==0>
            <thead>
                <tr>
                <th align="center" colspan="3">${item.quantity@label}</th>
                <th colspan="12">${item.item@label}</th>
                <th colspan="3">${item.options@label}</th>
                <th align="right" colspan="4">${item.rate@label}</th>
                <th align="right" colspan="4">${item.amount@label}</th>
                </tr>
            </thead>
        </#if>
        <#if item.item == bottomItemName>
            <#assign bottomItem = bottomItem + item>
        <#else>
            <tr>
                <td align="center" colspan="3" line-height="150%">${item.quantity}</td>
                <td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
                <td colspan="3">${item.options}</td>
                <td align="right" colspan="4">${item.rate}</td>
                <td align="right" colspan="4">${item.amount}</td>
            </tr>
        </#if>
    </#list>
    
    <#if bottomItem.item??>
        <tr>
            <td align="center" colspan="3" line-height="150%">${bottomItem.quantity}</td>
            <td colspan="12"><span class="itemname">${bottomItem.item}</span><br />${bottomItem.description}</td>
            <td colspan="3">${bottomItem.options}</td>
            <td align="right" colspan="4">${bottomItem.rate}</td>
            <td align="right" colspan="4">${bottomItem.amount}</td>
        </tr>
    </#if>
    

    【讨论】:

    • 谢谢贾拉,这行得通。我是编码新手,我应该查看哪种语言或资源来了解有关这些列表的操作的更多信息?
    • NetSuite 帮助中心有一个关于 HTML 和 FreeMarker for Scriptable Templates 的主题。 FreeMarker 的完整文档在这里:freemarker.apache.org/docs.
    【解决方案2】:

    您可以尝试循环 2x。

    <table class="itemtable" style="width: 100%; margin-top: 10px;"><!-- start items --><#list record.item as item><#if item_index==0>
    <thead>
        <tr>
        <th align="center" colspan="3">${item.quantity@label}</th>
        <th colspan="12">${item.item@label}</th>
        <th colspan="3">${item.options@label}</th>
        <th align="right" colspan="4">${item.rate@label}</th>
        <th align="right" colspan="4">${item.amount@label}</th>
        </tr>
    </thead>
    </#if><#if ${item.item}!="Your Item"><tr>
        <td align="center" colspan="3" line-height="150%">${item.quantity}</td>
        <td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
        <td colspan="3">${item.options}</td>
        <td align="right" colspan="4">${item.rate}</td>
        <td align="right" colspan="4">${item.amount}</td>
        </tr>
        </#list>
        <#list record.item as item><#if ${item.item}=="Your Item"><tr>
        <td align="center" colspan="3" line-height="150%">${item.quantity}</td>
        <td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
        <td colspan="3">${item.options}</td>
        <td align="right" colspan="4">${item.rate}</td>
        <td align="right" colspan="4">${item.amount}</td>
        </tr>
        </#list>
    

    我还没有测试 if 语句,祝你好运

    【讨论】:

    • 谢谢你,我收到了一些错误,没有进一步调查,因为这里的其他帖子的代码有效。再次感谢,
    猜你喜欢
    • 2018-01-01
    • 2019-11-09
    • 2021-07-04
    • 2018-01-02
    • 2018-05-03
    • 2018-01-10
    • 2013-04-18
    • 1970-01-01
    • 2020-07-18
    相关资源
    最近更新 更多