How to save data identifier into a local variable in a readonly grid?

Certified Associate Developer

Hi everyone, I'm facing issue while saving unique identifier value into a local variable. By default indexes are getting saved but I want to save the identifier value so that even if custom filters are applied only the actual selected value is checked/selected in the grid.

The working approach I came up till now is to convert my data into a datasubset using a!dataSubset and then use todatasubset with fv!pagingInfo from the grid. The issue which I found with this is todatasubset function is not able to over ride the paging configured by a!dataSubset, it could very well be an Appian issue not sure but due to this I'm getting full grid data in the screen. (Screenshot attached for this below)




If you know any workaround for this or any approach you implemented for this use case please share!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    Hey  ,  

    a!localVariables(
      local!selection,
      local!selectedEmployees,
      local!employeeDS: {
        {
          id: 11,
          name: "Sophia Turner",
          dept: "Marketing"
        },
        {
          id: 22,
          name: "Liam Brown",
          dept: "Operations"
        },
        {
          id: 33,
          name: "Emma Davis",
          dept: "Product Management"
        },
        {
          id: 44,
          name: "Oliver Martinez",
          dept: "Engineering"
        },
        {
          id: 55,
          name: "Ava Wilson",
          dept: "Customer Support"
        },
        { id: 66, name: "Noah Garcia", dept: "Sales" },
        {
          id: 77,
          name: "Isabella Lee",
          dept: "Human Resources"
        },
        { id: 88, name: "James Smith", dept: "IT" },
        {
          id: 99,
          name: "Mia Johnson",
          dept: "Finance"
        },
        { id: 111, name: "Ethan Brown", dept: "Legal" }
      },
      local!ds: a!dataSubset(
        data: local!employeeDS,
        startIndex: 1,
        batchSize: - 1,
        totalCount: length(local!employeeDS),
        identifiers: index(local!employeeDS, "id", {})
      ),
      {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!gridField(
                  label: "Employee Directory",
                  data: todatasubset(
                    arrayToPage: local!ds,
                    pagingConfiguration: fv!pagingInfo
                  ),
                  columns: {
                    a!gridColumn(
                      label: "Name",
                      sortField: "name",
                      value: fv!row.name
                    ),
                    a!gridColumn(
                      label: "Department",
                      sortField: "dept",
                      value: fv!row.dept
                    )
                  },
                  pageSize: 5,
                  selectable: true,
                  selectionValue: local!selection,
                  selectionSaveInto: {
                    local!selection,
                    a!save(
                      local!selectedEmployees,
                      index(
                        fv!selectedRows,
                        length(fv!selectedRows),
                        null
                      )
                    )
                  }
                )
              }
            )
          }
        )
      }
    )


    To simplify my question, I need to add pagination to the code above. How can I achieve this given I need the id to be stored in local!selection.

  • 0
    Certified Lead Developer
    in reply to deepakrana77

    you might need to consider handling converting the index to the primary key at the time of saving / retrieving row selections.  in the old iteration of paging grid, we were actually able to pass in the identifiers manually (though in many other ways it was far more painful to use), but that went away as of the 19.2 (modern) version.

Reply Children
No Data