Move columns
- Last Updated: April 12, 2024
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
You can use the MOVE-COLUMN() method to rearrange the columns within a browse.
For example, rather than forcing the users to scroll horizontally to see additional
columns, you might allow them to reorder the columns. MOVE-COLUMN takes
two arguments:
- The integer sequence within the browse of the column to move, counting from left to right
- The integer position to move the column to, again counting from left to right
The following simple example shows how to use the MOVE-COLUMN method
along with the START-SEARCH event and the column attributes introduced
earlier.
The START-SEARCH event occurs when the user clicks on the column header
for a browse with enabled columns. You can use this event to sort by column or for other
purposes. In this case, you want to identify which column position was selected and move
this column one position to the left.
To rearrange the columns you see first in the viewport without scrolling
Define this START-SEARCH trigger block for the
OrderBrowse:
|
Whenever you enter a trigger block, the SELF keyword evaluates to the
handle of the object that initiated the event. In this case, this is the browse itself,
not the browse column. The CURRENT-COLUMN attribute returns the handle
of the column the user clicked on.
The code initializes the hColumn handle variable to the first column in
the browse and then walks through all the columns, looking for the one with the same
handle as the browse’s CURRENT-COLUMN. This identifies the sequential
position of the one selected. The MOVE-COLUMN method moves this column
one position to the left, unless the user selected the first column.
You can also let the user simply drag columns left or right by setting the browse
COLUMN-MOVABLE attribute to true or an individual column’s
MOVABLE attribute to true, as described in Move the browse.