Skip to main content
kavyam0002
October 1, 2022
Solved

add row

  • October 1, 2022
  • 8 replies
  • 0 views

whenever i click on add it's creating blank row in in RI, but no in the interface 

    Best answer by harshitb6843

    Pass your Ri (crAPPContractExtension_cdt) in the items parameter of the a!forEach() function. 

    8 replies

    Participating Frequently
    October 1, 2022

    Can you share your code here are you using for loop to display rows?

    check line number 15

    a!localVariables(
      local!items: {
        { item: "Item 1", qty: 1, unitPrice: 10 },
        { item: "Item 2", qty: 2, unitPrice: 20 }
      },
      a!gridLayout(
        label: "Products",
        instructions: "Update the item name, quantity, or unit price.",
        headerCells: {
          a!gridLayoutHeaderCell(label: "Item"),
          a!gridLayoutHeaderCell(label: "Qty"),
          a!gridLayoutHeaderCell(label: "Unit Price"),
          a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
        },
        rows: a!forEach( /* loop to show all rows*/
          items: local!items,
          expression: a!gridRowLayout(
            contents: {
              a!textField(
                value: fv!item.item,
                saveInto: fv!item.item
              ),
              a!integerField(value: fv!item.qty, saveInto: fv!item.qty),
              a!floatingPointField(
                value: fv!item.unitPrice,
                saveInto: fv!item.unitPrice
              ),
              a!textField(
                value: tointeger(fv!item.qty) * todecimal(fv!item.unitPrice),
                readOnly: true,
                align: "RIGHT"
              )
            }
          )
        ),
        rowHeader: 1,
        addRowLink: a!dynamicLink(
          label: "Add row",
          saveInto: a!save(
            local!items,
            append(
              local!items,
              { item: null, qty: null, unitPrice: null }
            )
          )
        )
      )
    )a!localVariables(
      local!items: {
        { item: "Item 1", qty: 1, unitPrice: 10 },
        { item: "Item 2", qty: 2, unitPrice: 20 }
      },
      a!gridLayout(
        label: "Products",
        instructions: "Update the item name, quantity, or unit price.",
        headerCells: {
          a!gridLayoutHeaderCell(label: "Item"),
          a!gridLayoutHeaderCell(label: "Qty"),
          a!gridLayoutHeaderCell(label: "Unit Price"),
          a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
        },
        rows: a!forEach( /* loop to show all rows*/
          items: local!items,
          expression: a!gridRowLayout(
            contents: {
              a!textField(
                value: fv!item.item,
                saveInto: fv!item.item
              ),
              a!integerField(value: fv!item.qty, saveInto: fv!item.qty),
              a!floatingPointField(
                value: fv!item.unitPrice,
                saveInto: fv!item.unitPrice
              ),
              a!textField(
                value: tointeger(fv!item.qty) * todecimal(fv!item.unitPrice),
                readOnly: true,
                align: "RIGHT"
              )
            }
          )
        ),
        rowHeader: 1,
        addRowLink: a!dynamicLink(
          label: "Add row",
          saveInto: a!save(
            local!items,
            append(
              local!items,
              { item: null, qty: null, unitPrice: null }
            )
          )
        )
      )
    )

    kavyam0002
    October 1, 2022

    see i have written the same code

    but still it is not creating the row instead their are 13 rows it has created 13 rows by default

    Participating Frequently
    October 1, 2022

    Okay check that you are using a different variable for looping and when you are adding a new row you are using a different rule input. I think they should be same.

    rule input you are using for looping.

    rule input in which you are adding a new row.

    harshitb6843
    October 1, 2022

    Pass your Ri (crAPPContractExtension_cdt) in the items parameter of the a!forEach() function.