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
What will the real source for your data be? When you're querying from a data store entity, the data subset you start with includes the primary key IDs as the "identifiers" by default.
I do not feel very confident that I understand what you are trying to do. Can you help me out with more background, details and an explanation?
Data is from an external system so we can assume it to be a list of map. It is a multi selectable grid with custom filters.I converted it to a datasubset and provided it with an identifier. It works but now the paging is messed up for me since todatasubet is not able to over ride the initial paging. Also, if I try to play around directly with a!datasubset paging then it gives me again an error stating that batch size should be same like number of elements in the list.
I'm getting data from an external system, I need to show it on a grid which has custom filters. Using read only grid which automatically saves the identifier(if available) or the index of the list to the selection value. (For the checkbox or selection type)I need the data identifier to be saved so that even the filters changes the source data the checkbox is still selected for the already checked item and not just based on the index.
It's a read only multi selectable grid. The screenshot above is just for reference to show todatasubset is not able to override paging which is setted up by a!todatasubset.
Hey Mike Schmitt , Stefan Helzle
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 ) ) } ) } ) } ) } )
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.
try this variation:
a!localVariables( local!selection: {}, local!selectedEmployees, local!employeeList: { { 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!employeeList, startIndex: 1, batchSize: -1, totalCount: length(local!employeeList), identifiers: index(local!employeeList, "id", {}) ), { a!columnsLayout( columns: { a!columnLayout( contents: { a!gridField( label: "Employee Directory", data: todatasubset( arrayToPage: local!employeeList, 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: wherecontains(local!selection, local!employeeList.id), selectionSaveInto: { a!save( local!selection, if( a!isNullOrEmpty(save!value), {}, property( index(local!employeeList, save!value, {}), "id", {} ) ) ), /*a!save( local!selectedEmployees, index( fv!selectedRows, length(fv!selectedRows), null ) )*/ } ) } ) } ) } )
Ah in the chaotic identifier search I didn't thought the other way around. The OG wherecontains did the trick, thanks for your help!
Directly storing the identifiers works like a charm!
a!localVariables( local!selection: {}, local!pInfo: a!pagingInfo( startIndex: 1, batchSize: 5, sort: a!sortInfo("name", true) ), local!employeeList: { { 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" } }, /* Just sort the data */ local!sortedAndPaged: todatasubset( local!employeeList, local!pInfo ), /* The wrap it into a DS */ local!ds: a!dataSubset( data: local!sortedAndPaged.data, startIndex: local!pInfo.startIndex, batchSize: local!pInfo.batchSize, sort: local!pInfo.sort, totalCount: count(local!employeeList), identifiers: index(local!sortedAndPaged.data, "id", {}) ), { a!columnsLayout( columns: { a!columnLayout( contents: { a!gridField( label: "Employee Directory", data: local!ds, columns: { a!gridColumn( label: "Name", sortField: "name", value: fv!row.name ), a!gridColumn( label: "Department", sortField: "dept", value: fv!row.dept ) }, selectable: true(), selectionValue: local!selection, selectionSaveInto: local!selection, pagingSaveInto: local!pInfo ) } ) } ) } )
Thanks Stefan!