I am looking for a way to page an array of CDTs in an editable grid. The caveat is that I need the data to persist across pages. Has anyone done this before? Some code examples would be great.
Discussion posts and replies are publicly visible
Editable grids don't allow pagination. When you say "persist the data across pages", I'm assuming that you're updating the data in the grid and want it to stay there. If I understand you correctly, here is the sample code to achieve the task: https://docs.appian.com/...editable-grid
If I misunderstood you, could you please elaborate a little further about your use case? Do you want to create custom pagination? Or do you already have it and want to persist the data when you paginate through it?
I know that editable grids don't have OOTB paging, which is why I am trying to build it. By persist, I mean if the user updates fields for a row on one page, and then pages to the next page, and then page back to the previous page, they will still see the data that they updated.
Will your array of CDT remain the same? I mean, is there any chance that you'll be re-loading it with the new data every time you paginate through the grid?
It should remain the same, besides the field that the user may update in the grid.
Then the aforementioned sample code with a small tweak will do the job. Try this with your custom pagination:
a!localVariables( local!items: { {item: "Item 1", qty: 1}, {item: "Item 2", qty: 2}, {item: "Item 3", qty: 1}, {item: "Item 4", qty: 3}, {item: "Item 5", qty: 4} }, a!gridLayout( label: "Products", headerCells: { a!gridLayoutHeaderCell(label: "Item"), a!gridLayoutHeaderCell(label: "Qty") }, rows: a!forEach( items: local!items, expression: a!gridRowLayout( contents: { a!textField( value: local!items[fv!index].item, saveInto: local!items[fv!index].item ), a!integerField( value: local!items[fv!index].qty, saveInto: local!items[fv!index].qty ) } ) ) ) )
Change the details as per your requirement. Hope it helps.