Unable to save selected rows in gridRowLayout to a local variable

Hi everyone,

I need help checking whether I’m doing something wrong with my code.

I’m having an editable grid with data is a data subset local variable. In it’s gridRowLayout() I also provided the id parameter. But somehow when selecting the row, it does not save any data to local!selectedAzureId. I also tried with fv!index instead of fv!item.fileId but did not work either.

{
   a!gridLayout(
     label: "Documents",
     labelPosition: "COLLAPSED",
     headerCells: {},
     columnConfigs: {},
     rows: a!forEach(
       items: local!data.data,
       expression: a!gridRowLayout(
         id: fv!item.fileId,
         contents: {}
       )
     ),
     selectable: true,
     selectionValue: local!selectedAzureIds,
     selectionSaveInto: {
       a!save(
         local!selectedAzureIds,
         a!flatten(save!value)
       ),
       a!save(
         ri!selectedAzureIds,
         local!selectedAzureIds
       ),
 
     },
     rowHeader: 1,
     showWhen: rule!AAA_CMN_IsEmpty(local!curDoc),
 
   ),

And below is local!data – the gridLayout data source:

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    i am assuming you have intentionally removed the headerCells and content of. a!gridRowLayout .

    check if there is typo in the fv!item.fileId . not sure why fv!index didnt work out for you. Below code worked.

    a!localVariables(
      local!data: todatasubset({
        {fileId: 1, qty: 1, unitPrice: 10},
        {fileId: 2, qty: 2, unitPrice: 20}
      }),
      local!selectedAzureIds:tointeger({}),
      {
        a!gridLayout(
          label: "Documents",
          labelPosition: "COLLAPSED",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Item"),
            a!gridLayoutHeaderCell(label: "Qty"),
            a!gridLayoutHeaderCell(label: "Unit Price"),
            a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
          },
          columnConfigs: {},
          rows: a!forEach(
            items: local!data.data,
            expression: a!gridRowLayout(
              id: fv!item.fileId,
              contents: {
                
                  a!textField(
                    value: fv!item.fileId,
                    saveInto: fv!item.fileId
                  ),
                  a!integerField(
                    value: fv!item.qty,
                    saveInto: fv!item.qty
                  ),
                  a!floatingPointField(
                    value: fv!item.unitPrice,
                    saveInto: fv!item.unitPrice
                  ),
                  a!textField(
                    value: a!currency(
                      isoCode: "USD",
                      value: tointeger(fv!item.qty) * todecimal(fv!item.unitPrice)
                    ),
                    readOnly: true,
                    align: "RIGHT"
                  )
              }
            )
          ),
          selectable: true,
          selectionValue: local!selectedAzureIds,
          selectionSaveInto: {
            a!save(
              local!selectedAzureIds,
              a!flatten(save!value)
            ),
            
    
          },
          rowHeader: 1,
          
    
        ),}
    )

Reply
  • 0
    Certified Lead Developer

    i am assuming you have intentionally removed the headerCells and content of. a!gridRowLayout .

    check if there is typo in the fv!item.fileId . not sure why fv!index didnt work out for you. Below code worked.

    a!localVariables(
      local!data: todatasubset({
        {fileId: 1, qty: 1, unitPrice: 10},
        {fileId: 2, qty: 2, unitPrice: 20}
      }),
      local!selectedAzureIds:tointeger({}),
      {
        a!gridLayout(
          label: "Documents",
          labelPosition: "COLLAPSED",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Item"),
            a!gridLayoutHeaderCell(label: "Qty"),
            a!gridLayoutHeaderCell(label: "Unit Price"),
            a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
          },
          columnConfigs: {},
          rows: a!forEach(
            items: local!data.data,
            expression: a!gridRowLayout(
              id: fv!item.fileId,
              contents: {
                
                  a!textField(
                    value: fv!item.fileId,
                    saveInto: fv!item.fileId
                  ),
                  a!integerField(
                    value: fv!item.qty,
                    saveInto: fv!item.qty
                  ),
                  a!floatingPointField(
                    value: fv!item.unitPrice,
                    saveInto: fv!item.unitPrice
                  ),
                  a!textField(
                    value: a!currency(
                      isoCode: "USD",
                      value: tointeger(fv!item.qty) * todecimal(fv!item.unitPrice)
                    ),
                    readOnly: true,
                    align: "RIGHT"
                  )
              }
            )
          ),
          selectable: true,
          selectionValue: local!selectedAzureIds,
          selectionSaveInto: {
            a!save(
              local!selectedAzureIds,
              a!flatten(save!value)
            ),
            
    
          },
          rowHeader: 1,
          
    
        ),}
    )

Children