I'm currently creating a report program with a freeform query.
Some users requested about the possibility of sorting by any of these columns. This part itself is done, and it´s working.
My question is:
Using the BROWSE br:CURRENT-COLUMN
, how can I get the index to use into SET-SORT-ARROW()
?
This is my working code:
DO:
DEFINE VARIABLE hCol AS HANDLE.
DEFINE VARIABLE qh AS HANDLE.
IF cBrowserSort = "" THEN
cBrowserSort = "DESCENDING" .
ELSE
cBrowserSort = "".
ASSIGN hCol = BROWSE br:CURRENT-COLUMN
qh = QUERY br:HANDLE
cBy = "by temp" + STRING(hCol:NAME).
qh:QUERY-PREPARE("FOR EACH TT-Component NO-LOCK BY " + hCol:NAME + " " + cBrowserSort + ":").
qh:QUERY-OPEN().
br:CLEAR-SORT-ARROWS().
//br:SET-SORT-ARROW(hCol:NAME, cBrowserSort EQ "").
END.
You need to loop through the browse columns to find the column whose widget handle matches the column you need.
def var hBrowse as handle no-undo.
def var lFound as logical no-undo.
def var ix as integer no-undo.
hBrowse = browse br:handle.
do ix = 1 to hBrowse:num-columns while not lFound:
if hBrowse:get-browse-column(ix) = hCol then
lFound = true.
end.
if lFound then
hBrowse:set-sort-arrow( ix - 1, cBrowserSort = '' ).