Skip to content

Nested loop not working as expected #240

@junwen-k

Description

@junwen-k

Greetings, thank you for this amazing library.

I am currently facing some issue defining nested loop (loop within loop), which I think is pretty common in reporting.

Template:

image

With the example view model:

{
  "transactionGroups": [
    {
      "title": "My Group",
      "transactions": [
        {
          "transactionNo": "Transaction No 1",
          "referenceNo": "Reference No 1",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 2",
          "referenceNo": "Reference No 2",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 3",
          "referenceNo": "Reference No 3",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 4",
          "referenceNo": "Reference No 4",
          "amount": 1000
        }
      ]
    },
    {
      "title": "My Second Group",
      "transactions": [
        {
          "transactionNo": "Transaction No 5",
          "referenceNo": "Reference No 5",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 6",
          "referenceNo": "Reference No 6",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 7",
          "referenceNo": "Reference No 7",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 8",
          "referenceNo": "Reference No 8",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 9",
          "referenceNo": "Reference No 9",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 10",
          "referenceNo": "Reference No 10",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 11",
          "referenceNo": "Reference No 11",
          "amount": 1000
        },
        {
          "transactionNo": "Transaction No 12",
          "referenceNo": "Reference No 12",
          "amount": 1000
        }
      ]
    }
  ]
}

Output

image

Expected

image

I am just experimenting around and if this works, I would also need to add in the grand total which takes the SUM of all Subtotal cell etc. However I couldn't get this first step working, suspect there is something wrong with nested loop. (The second group loop begins with transaction 10 which is odd, seems like it is "continueing" from the first group iteration or something)

Thank you and hope to hear from you soon!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions