Hi, I have readable grid in which i am using arrow icon, so if I click on that arrow so that row should go up and upper row should come down. I can get all data items from current row, but how I will get data from previous row, So I can apply swapping conditiin
Discussion posts and replies are publicly visible
HI shubhamsingh
Use the below code in saveinto parameter of your dynamic link for moving up
a!save( local!data, insert(local!data, fv!item, fv!index - 1) ), a!save( local!data, remove(local!data, fv!index + 1) )
Use the below code in saveinto parameter of your dynamic link for moving down
a!save( local!data, insert(local!data, fv!item, fv!index + 2) ), a!save( local!data, remove(local!data, fv!index) )
yes it will not start with 1 on second page it will continue assigning unique identifier to each row. So my theory here is - as we don't want the index of the item according to the current page but the index of the item according to the whole data right? so fv!identifer will provide the current index of the item according to the whole data, working in place of wherecontains in grid and this scenarios
It will break. fv!identifier gives you the primary key. So if you are in the second page, fv!identifier will not start with 1. Hence fv!identifier <> fv!index
just for learning purpose, is it good to have 3 where contains per row in a grid where we can use fv!identfier? or it will break in any corner cases?
Have been using it for ages. Did not find any issue :)
I believe instead of using this
wherecontains(fv!row, ri!data)
fv!identfier
Thanks. Done :-)
As Appian suggests, now you should replace it with a!update()
Find below my generic expression to swap two items in a list.
if( and( not(rule!PCO_IsVoid(ri!list)), ri!index1 > 0, ri!index1 <= count(ri!list), ri!index2 > 0, ri!index2 <= count(ri!list), ri!index1 <> ri!index2 ), updatearray( ri!list, {ri!index1, ri!index2}, {ri!list[ri!index2], ri!list[ri!index1]} ), ri!list )
Here is a much more optimized version of what you are trying to do for the editable grid.
a!save( ri!data, a!update( ri!data, { fv!index, fv!index + 1 }, { ri!data[fv!index + 1], fv!item } ) )