add grid automatically

Hi 

my requirements is i have 2 grids one after the other when i add a row in the first grid i have to get one row automatically in the 2nd grid [second grid will be user input grid]

can anyone help me on this 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi, 

    While using the editable grids we have a parameter as addRowLink there you can append new values to both the items which you are using for the grids.

  • Hi Ujjwal,

    can you help me with the sample code so that it will  be helpful for me. i have tried but not getting 

  • 0
    Certified Lead Developer
    in reply to KM

    Try to ignore the grids and concentrate on manipulating the underlying data stored in rule inputs or locals.

    Please try to explain what you tried and what failed. Do you have some code snippets you can share?

  • +1
    Certified Lead Developer
    in reply to KM

    Check this out..

    = a!localVariables(
      local!items: { { item: null, qty: null, unitPrice: null },  },
      local!item2: { { item_grid: null, item_qty: null } },
      {
        a!gridLayout(
          label: "Products1",
          instructions: "Update the item name, quantity, or unit price.",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Item"),
            a!gridLayoutHeaderCell(label: "Qty"),
            a!gridLayoutHeaderCell(label: "Unit Price"),
            
          },
          rows: a!forEach(
            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
                  ),
                  
                }
              )
            }
          ),
          rowHeader: 1,
          addRowLink: a!dynamicLink(
            label: "Add new row",
            saveInto: {
              a!save(
                local!items,
                append(
                  local!items,
                  { item: null, qty: null, unitPrice: null }
                )
              ),
              a!save(
                local!item2,
                append(
                  local!item2,
                  { item_grid: null, item_qty: null }
                )
              )
            }
          )
        ),
        a!gridLayout(
          label: "Products2",
          instructions: "Update the item name, quantity, or unit price.",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Item"),
            a!gridLayoutHeaderCell(label: "Qty"),
            
          },
          rows: a!forEach(
            items: local!item2,
            expression: {
              a!gridRowLayout(
                contents: {
                  a!textField(
                    value: fv!item.item_grid,
                    saveInto: fv!item.item_grid
                  ),
                  a!integerField(
                    value: fv!item.item_qty,
                    saveInto: fv!item.item_qty
                  ),
                  
                }
              )
            }
          ),
          rowHeader: 1,
          addRowLink: a!dynamicLink(
            label: "Add new row",
            saveInto: {
              a!save(
                local!item2,
                append(
                  local!item2,
                  { item_grid: null, item_qty: null }
                )
              ),
              a!save(
                local!items,
                append(
                  local!items,
                  { item: null, qty: null, unitPrice: null }
                )
              )
            }
          )
        )
      }
    )

Reply
  • +1
    Certified Lead Developer
    in reply to KM

    Check this out..

    = a!localVariables(
      local!items: { { item: null, qty: null, unitPrice: null },  },
      local!item2: { { item_grid: null, item_qty: null } },
      {
        a!gridLayout(
          label: "Products1",
          instructions: "Update the item name, quantity, or unit price.",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Item"),
            a!gridLayoutHeaderCell(label: "Qty"),
            a!gridLayoutHeaderCell(label: "Unit Price"),
            
          },
          rows: a!forEach(
            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
                  ),
                  
                }
              )
            }
          ),
          rowHeader: 1,
          addRowLink: a!dynamicLink(
            label: "Add new row",
            saveInto: {
              a!save(
                local!items,
                append(
                  local!items,
                  { item: null, qty: null, unitPrice: null }
                )
              ),
              a!save(
                local!item2,
                append(
                  local!item2,
                  { item_grid: null, item_qty: null }
                )
              )
            }
          )
        ),
        a!gridLayout(
          label: "Products2",
          instructions: "Update the item name, quantity, or unit price.",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Item"),
            a!gridLayoutHeaderCell(label: "Qty"),
            
          },
          rows: a!forEach(
            items: local!item2,
            expression: {
              a!gridRowLayout(
                contents: {
                  a!textField(
                    value: fv!item.item_grid,
                    saveInto: fv!item.item_grid
                  ),
                  a!integerField(
                    value: fv!item.item_qty,
                    saveInto: fv!item.item_qty
                  ),
                  
                }
              )
            }
          ),
          rowHeader: 1,
          addRowLink: a!dynamicLink(
            label: "Add new row",
            saveInto: {
              a!save(
                local!item2,
                append(
                  local!item2,
                  { item_grid: null, item_qty: null }
                )
              ),
              a!save(
                local!items,
                append(
                  local!items,
                  { item: null, qty: null, unitPrice: null }
                )
              )
            }
          )
        )
      }
    )

Children
No Data