The program sorts grid rows using the ImageGrid() --> "MOVE_UP" and "MOVE_DOWN" approach (Code copied below). Currently, when I re-launch the program all sorts are undone. I want the grid to save the new order after rows have been moved around.Is that possible? Is there an out of the box function I can use? If you can, please share an example.
a!imageField( label: "delete " & fv!index, images: a!documentImage( document: a!iconIndicator( "MOVE_UP" ), altText: "Remove", caption: "Move Up: " & fv!item.name, link: a!dynamicLink( value: fv!index, saveInto: { if( fv!index = 1, {}, { a!save( local!A, insert( local!A, fv!item, fv!index - 1 ) ), a!save( local!A, remove( local!A, fv!index + 1 ) ) } ) } ) ), size: "ICON" ),
Discussion posts and replies are publicly visible
The ordering of local!A will alwyas be the default ordering of the grid. If you wish to make its order something else, then you would need to add a column to store the sort orders into, and that would be one of the targets of the save performed by the "move up / move down" controls. I assume you're getting this data from the DB (though you didn't specify), so this would need to be persisted to the DB to apply to the next time the form loads as well.
Hi David, as told by Mike if your getting data from db, then make sure that you are not moving the primary key up and down if you are having that in your sorting data.
Example:
1.A
2.B
3.C
Sorting it and saving it in db
1.B
2.A
result when retrieving again
if you move the entire row along with the id which is a primary key and save it in db then it will give the same result every time you retrieve.
May you find this usefull....
Data is being pulled from the Cloud database Table. Wouldn't it be easier to sort at the database level and then pull data? I have read this can be done using "Order By". Does Appian information online about this process. I haven't found anything on this process (at least that I am aware of).
I recommend you refer back to my initial comment. You would add a data column that stores an integer value representing the relative sort order of individual items, and then sort by that during query on-form.