a!gridRowLayOut() sorting: How to save sort order in grid?

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

Parents
  • 0
    Certified Lead Developer

    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.

Reply
  • 0
    Certified Lead Developer

    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.

Children