Switch the values from table records

I am trying create an ordenation inside a table records, what I have is one column that has the order of which element, when I press the icon (up arrow) I need to switch the value from the current the element above it.

When I press the icon (down arrow) I need to switch the value from current to the element beneath it. Is there a way I can switch the elements by this icon?

Hi leo!

To achieve this I would add a server action to the icons. Then just swap the order attribute from one record with the previous (or next, depending if you've pressed up or down) and refresh the table. Note, the table must be ordered by your ORDER column.

Cheers,

Joao

Joao Duro wrote:

Hi leo!

To achieve this I would add a server action to the icons. Then just swap the order attribute from one record with the previous (or next, depending if you've pressed up or down) and refresh the table. Note, the table must be ordered by your ORDER column.

Cheers,

Joao

But how can I get the previous order and switch to the current, how can I swap the values?


Hi leo ferreira,

Take a look into the List Move widget from RichWidgets.

Thanks,
Samuel

leo ferreira wrote:

Joao Duro wrote:

Hi leo!

To achieve this I would add a server action to the icons. Then just swap the order attribute from one record with the previous (or next, depending if you've pressed up or down) and refresh the table. Note, the table must be ordered by your ORDER column.

Cheers,

Joao

But how can I get the previous order and switch to the current, how can I swap the values?



Hi Leo,

to do that you must access the previous or the next record from your table/List, something like:

previous:

TableRecords.List[TableRecords.List.CurrentRowNumber - 1].Record.Order


next:

TableRecords.List[TableRecords.List.CurrentRowNumber + 1].Record.Order

then you can add or subtract to the order depending if ordering up or down.

But I guess the solution proposed by Samuel is easier to handle.

(if you send an oml we can take a look and help you better)

Cheers!



Hi Leo,

Instead of using arrows did you think on using drag and drop? You can accomplish that with this component. Just suggesting because my clients always prefer it like this.

Regards,

Marcelo