简体   繁体   English

$formatNumber 在表数组中使用时输出 NaN

[英]$formatNumber outputs NaN when used in table array

I'm applying number formatting to a PDF document, which works fine in a 'parent' record in the JSON data, but fails when used inside a table.我正在将数字格式应用于 PDF 文档,它在 JSON 数据的“父”记录中工作正常,但在表中使用时失败。 How can I get the $formatNumber expression to work inside an array of data?如何让 $formatNumber 表达式在数据数组中工作?

The data is being merged into an invoice document, and in one of the columns of the "Invoice Line Items" I'd like to format the number with the expression $formatNumber, '#,###.00'.数据正在合并到发票文档中,在“发票行项目”的其中一列中,我想用表达式 $formatNumber, '#,###.00' 格式化数字。

Here is the merge syntax in my word document:这是我的 word 文档中的合并语法:

This formatting works fine for the parent data: {{ $formatNumber(QuoteLineItems.totalSize, '#,###.00') }}此格式适用于父数据:{{ $formatNumber(QuoteLineItems.totalSize, '#,###.00') }}

This formatting fails when used inside a table (the output in the PDF si "NaN") {{ $formatNumber(QuoteLineItems.records.AmountNet, '#,###.00') }}在表格中使用时,此格式会失败(PDF si“NaN”中的输出){{ $formatNumber(QuoteLineItems.records.AmountNet, '#,###.00') }}

Image: Comparison of Success vs Failure syntax图片:成功与失败语法的比较

Image: PDF Output contains NaN in table图像:PDF 输出在表中包含 NaN

here is the sample input data I am using inside the word plugin document tagger:这是我在 word 插件文档标记器中使用的示例输入数据:

{
    "QuoteLineItems":
    {
        "records":
        [
            {
                "AmountGross": 47897,
                "AmountNet": 44556,
                "Name": "Sample Charges"
            },
            {
                "AmountGross": 4968,
                "AmountNet": 4621,
                "Name": "Sample 2 Charges"
            }
        ],
        "done": true,
        "totalSize": 2
    },
    "Name": "Sample Invoice"
}

Sorry for the delay in answering this.很抱歉延迟回答这个问题。 This is a known bug (I'm going to check on the status).这是一个已知的错误(我将检查状态)。 For now I suggest doing your number format in your code before sending it to the API.现在,我建议在将代码发送到 API 之前在代码中设置您的数字格式。 If that doesn't make sense, let me know and I'll clarify.如果这没有意义,请告诉我,我会澄清。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM