If I selected one row in editable grid then it should deselect all other rows except selected row

Certified Senior Developer

Expected behaviour: If i selected one row in editable grid then it should deselect all other rows except selected row , 

Actual behaviour: It is deselecting all remaining row whenever Iam selecting any row in editable grid,

a!localVariables(
  local!selectionIndex:tointeger({}),
  local!data:{
    {id:1,name:"Pavani"},
  {id:2,name:"Sravani"},
  {id:3,name:"Srani"},
    {id:4,name:"Sri"},
  },
  a!gridLayout(
    headerCells: {
      a!gridLayoutHeaderCell(
        label: "Id"
      )
    },
    rows:a!forEach(
      items: local!data,
      expression: {
        a!gridRowLayout(
          id: fv!index,
          selectionDisabled: if(a!isNullOrEmpty(local!selectionIndex),{},
          if(count(local!selectionIndex)=fv!itemCount,false(),true())),
          contents:a!integerField(
            label: "Id",
            value: fv!item.id,
            saveInto: fv!item.id
            
           
          ),
           ),
       
      }
    ),
    selectable: true(),
    rowHeader: 1,
    
    selectionValue: local!selectionIndex,
    selectionSaveInto: a!save(
      local!selectionIndex,
     save!value
    )
   
  )
)

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to laxmipavanik0001

    a!localVariables(
      local!items: {
        {item: "Item 1", qty: 1, unitPrice: 10},
        {item: "Item 2", qty: 2, unitPrice: 20}
      },
      local!selected: tointeger({}),
      a!gridLayout(
        label: "Products",
        instructions: "Selected: " & local!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!selected,
        /* Flatten the selected values so the result is easier to work with */
        /* when the select/deselect all option is used in an editable grid  */
        selectionSaveInto: {
          a!save(
            target: local!selected,
            value: a!flatten(save!value)
          ),
          a!save(
            target: local!selected,
            value: index(local!selected, count(local!selected), null)
          ),
        },
        rowHeader: 1
      )
    )