Selection in a grid using select all and deselect All functionality

Certified Associate Developer

HI All , 

I am trying to select the value in a readonly grid by select all and deselect all functionality in a grid . I am not able to achieve this . below is the snippet of my code . please help me  out . 

a!localVariables(
  local!data1: { { name: "Java" }, { name: "Python" } },
  local!selectedRowData,
  local!pageSize: 25,
  local!defaultActivityPaging: a!pagingInfo(
    1,
    local!pageSize,
    a!sortInfo("name", true)
  ),
  local!activityPaging: local!defaultActivityPaging,
  local!gridselectedsNumber,
  local!selection,
  local!isDeselectAllDisabled: or(
    length(local!data1) > 100,
    a!isNullOrEmpty(local!selection)
  ),
  local!isSelectAllDisabled: or(
    length(local!data1) > 100,
    length(local!data1) = 0
  ),
  {
    a!columnsLayout(
      columns: {
        a!columnLayout(
          contents: {
            a!richTextDisplayField(
              value: {
                a!richTextIcon(
                  icon: "question-circle",
                  caption: "Selection will only apply to filtered records",
                  color: "#1D659C"
                ),
                " ",
                a!richTextIcon(
                  icon: "square-o",
                  caption: if(
                    local!isDeselectAllDisabled,
                    "No Records selected",
                    {}
                  ),
                  color: if(
                    local!isDeselectAllDisabled,
                    {},
                    "ACCENT"
                  )
                ),
                a!richTextItem(
                  text: " Deselect All",
                  link: if(
                    local!isDeselectAllDisabled,
                    {},
                    a!dynamicLink(
                      label: "Deselect All",
                      saveInto: {
                        a!save(
                          local!selection,
                          difference(
                            touniformstring(local!selection),
                            touniformstring(local!data1)
                          )
                        ),
                        
                      }
                    )
                  ),
                  linkStyle: "STANDALONE"
                ),
                " | ",
                a!richTextIcon(
                  icon: "check-square-o",
                  caption: if(
                    local!isSelectAllDisabled,
                    "Limit filtered list below " & 100 & " records",
                    {}
                  ),
                  linkStyle: "STANDALONE",
                  color: if(local!isSelectAllDisabled, {}, "ACCENT")
                ),
                a!richTextItem(
                  text: " Select All",
                  link: if(
                    local!isSelectAllDisabled,
                    {},
                    a!dynamicLink(
                      label: "Select All",
                      value: {},
                      saveInto: {
                        a!save(
                          local!selection,
                          reject(
                            a!isNullOrEmpty(),
                            union(
                              touniformstring(local!selection),
                              touniformstring(local!data1)
                            )
                          )
                        ),
                        a!save(
                          local!gridselectedsNumber,
                          local!selection
                        )
                      }
                    )
                  ),
                  linkStyle: "STANDALONE"
                )
              },
              align: "RIGHT"
            )
          }
        )
      },
      alignVertical: "BOTTOM"
    ),
    a!gridField(
      labelPosition: "ABOVE",
      data: local!data1,
      columns: {
        a!gridColumn(
          label: "name",
          sortField: "name",
          value: fv!row.name,
          align: "START"
        ),
        
      },
      pagingSaveInto: local!activityPaging,
      selectable: true,
      selectionValue: local!selection,
      selectionSaveInto: {
        local!selection,
        a!save(
          local!selectedRowData,
          append(local!selectedRowData, fv!selectedRows)
        ),
        a!save(
          local!selectedRowData,
          difference(
            local!selectedRowData,
            fv!deselectedRows
          )
        ),
        
      },
    )
  }
)

Thanks in advance

  Discussion posts and replies are publicly visible