display the result of a view in an editable grid

I am planning to display the result of a view in an editable grid . Can anyone please give me an example ? 

The number of rows is fixed but i dont want to write  a!gridRowLayout() 44 times as shown in the example of 2 rows

 

=load(
  local!items: {
    {item: "Item 1", qty: 1, unitPrice: 10},
    {item: "Item 2", qty: 2, unitPrice: 20}
  },
  a!gridLayout(
    label: "Grid Layout",
    instructions: "This is a grid layout",
    headerCells: {
      a!gridLayoutHeaderCell(label: "Item"),
      a!gridLayoutHeaderCell(label: "Qty", align: "RIGHT"),
      a!gridLayoutHeaderCell(label: "Unit Price", align: "RIGHT"),
      a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
    },
    rows: {
      a!gridRowLayout(
        contents: {
            a!textField(
            value: local!items[1].item,
            saveInto: local!items[1].item
          ),
          a!integerField(
            value: local!items[1].qty,
            saveInto: local!items[1].qty,
            align: "RIGHT"
          ),
          a!floatingPointField(
            value: local!items[1].unitPrice,
            saveInto: local!items[1].unitPrice,
            align: "RIGHT"
          ),
          a!textField(
            value: dollar(tointeger(local!items[1].qty) * todecimal(local!items[1].unitPrice)),
            readOnly: true,
            align: "RIGHT"
          )
        }
      ),
      a!gridRowLayout(
        contents: {
          a!textField(
            value: local!items[2].item,
            saveInto: local!items[2].item
          ),
          a!integerField(
            value: local!items[2].qty,
            saveInto: local!items[2].qty,
            align: "RIGHT"
          ),
          a!floatingPointField(
            value: local!items[2].unitPrice,
            saveInto: local!items[2].unitPrice,
            align: "RIGHT"
          ),
          a!textField(
            value: dollar(tointeger(local!items[2].qty) * todecimal(local!items[2].unitPrice)),
            readOnly: true,
            align: "RIGHT"
          )
        }
      )
    }
  )
)

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to naveenp878
    There can be a use case, when your view returns duplicate Primary Key value (which is rare), when you go for pagingGrid, it will throw an error, because pagingGrid expects unique identifier, so in such cases we need to go for editable grid with readOnly field.

    Now when we talk about hardcoding, as per my understanding a!forEach() function which was released in 17.2 version, will be the best choice as already have explained above.

    Hope this will help you.
Children
No Data