Skip to main content
August 10, 2024
Solved

grid deselection at header level doesnt work

  • August 10, 2024
  • 4 replies
  • 0 views

hi, 

I have an editable grid and have selection enabled, it works perfectly fine , when selecting individual rows and as bulk when i chose the check box in the header, 

This works 

when i unselect at header , it throws error but individual row deselection works, only deselection in the header is not working 

code :at line 507

selectionValue: local!selectedIndex,
selectionSaveInto: {
local!selectedIndex,a!save(local!selectedrows,index(local!displayItems,local!selectedIndex))},

    Best answer by yogip3177

    You can try by replacing following code:

    selectionSaveInto: {
          a!save(
            local!selectedIndex,
            a!flatten(save!value)
          ),
          a!save(
            local!selectedrows,
            if(
              a!isNullOrEmpty(local!selectedIndex),
              {},
              index(local!items, local!selectedIndex)
            )
          )
        }

    4 replies

    August 11, 2024

    Hi [mention:92ba06295fbc4d77b281c512999a858b:e9ed411860ed4f2ba0265705b8793d05] ,

    just try this logic

    a!localVariables(
      local!items: {
        { item: "Item 1", qty: 1, unitPrice: 10 },
        { item: "Item 2", qty: 2, unitPrice: 20 }
      },
      local!selecteditems,
      a!gridLayout(
        label: "Products",
        instructions: "Selected: ",
        headerCells: {
          a!gridLayoutHeaderCell(label: "Item"),
          a!gridLayoutHeaderCell(label: "Qty"),
          a!gridLayoutHeaderCell(label: "Unit Price"),
          a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
        },
        rows: a!forEach(
          items: local!items,
          expression: a!gridRowLayout(
            id: fv!index,
            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: a!currency(
                  isoCode: "USD",
                  value: tointeger(fv!item.qty) * todecimal(fv!item.unitPrice)
                ),
                readOnly: true,
                align: "RIGHT"
              )
            }
          )
        ),
        selectable: true(),
        selectionValue: local!selecteditems,
        selectionSaveInto: a!save(
          local!selecteditems,
          a!flatten(save!value)
        ),
        rowHeader: 1
      )
    )
    , i think this can help you to achieve your requirement.

    yogip3177Answer
    August 11, 2024

    You can try by replacing following code:

    selectionSaveInto: {
          a!save(
            local!selectedIndex,
            a!flatten(save!value)
          ),
          a!save(
            local!selectedrows,
            if(
              a!isNullOrEmpty(local!selectedIndex),
              {},
              index(local!items, local!selectedIndex)
            )
          )
        }

    August 12, 2024

    This works thank you 

    kumara0180
    August 12, 2024