moving browse column

snooker

New Member
I want to move one column in a browse widget by using it's column-label and the current position number in the browse widget.
MOVE-COLUMN(i,j) method doesnt work for me properly. I need another solution. If someone can help me, I will be glad.

Thanks in advance...
 
I found a solution... I do this by using two different temp-tables. It is quite a long solution and not a one-step solution. We should use two different procedures, and we should call these procedures in different parts of the whole programme.

First at the beginning of the programme, I store the first sorting-order of the browse in the first temp-table "temp-table-1".

Code:
[COLOR=#0000ff]PROCEDURE[/COLOR] first-views:
[COLOR=#0000ff]DEF VAR[/COLOR] jj [COLOR=#0000ff]AS INT[/COLOR].
[COLOR=#0000ff]DEFINE VARIABLE [/COLOR]cur-col [COLOR=#0000ff]AS WIDGET-HANDLE[/COLOR].

cur-col = [COLOR=#0000ff]BROWSE[/COLOR] browse-name:[COLOR=#0000ff]FIRST-COLUMN[/COLOR].
[COLOR=#0000ff]DO[/COLOR] jj = 1 [COLOR=#0000ff]TO[/COLOR] browse-name:[COLOR=#0000ff]NUM-COLOUMNS[/COLOR]:
    [COLOR=#0000ff]IF[/COLOR] jj > 1 THEN cur-col = cur-col:[COLOR=#0000ff]NEXT-COLUMN[/COLOR].
    [COLOR=#0000ff]CREATE[/COLOR] temp-table-1
    [COLOR=#0000ff]ASSIGN[/COLOR]
        col-name = cur-col:[COLOR=#0000ff]NAME[/COLOR]
        col-order = jj.
[COLOR=#0000ff]END[/COLOR].
[COLOR=#0000ff]END PROCEDURE[/COLOR].

After the other procedures run in the program.. I store last sorting-orders of the browse in the second temp-table "temp-table-2".

Code:
[COLOR=#0000ff]PROCEDURE [/COLOR]last-views:
[COLOR=#0000ff]DEF VAR[/COLOR] jj [COLOR=#0000ff]AS INT[/COLOR].
[COLOR=#0000ff]DEF VAR [/COLOR]aa [COLOR=#0000ff]AS INT[/COLOR].

jj = browse-name:NUM-[COLOR=#0000ff]COLUMNS
[/COLOR][COLOR=#000000]aa = 1.[/COLOR]
[COLOR=#0000ff]IF [/COLOR]field-01 will be shown at the end of the browse [COLOR=#0000ff]THEN DO[/COLOR]:
[COLOR=#0000ff]CREATE [/COLOR]temp-table-2.
    [COLOR=#0000ff]ASSIGN [/COLOR]
        temp-table-2.col-name  = field-01
        temp-table-2.col-order  = jj.
    jj = jj - 1.
[COLOR=#0000ff]END.
END[/COLOR].
[COLOR=#0000ff]IF [/COLOR]field-01 will be shown at the beginning of the browse [COLOR=#0000ff]THEN DO[/COLOR]:
    [COLOR=#0000ff]CREATE [/COLOR]temp-table-2.
    [COLOR=#0000ff]ASSIGN [/COLOR]
        temp-table-2.col-name  = field-01
        temp-table-2.col-order  = aa.
    aa = aa + 1.
[COLOR=#0000ff]END[/COLOR].

/* The below code is set the our last view as the first view for the next arrangements of the browse view. 
    It moves the columns by comparing the first view and last view. 
    At the end of the procedure we empty temp-table "temp-table-2" for reseting last view positions in the browse 
*/

[COLOR=#0000ff]DEF VAR [/COLOR]old-pos [COLOR=#0000ff]AS INT[/COLOR].
[COLOR=#0000ff]DEF VAR[/COLOR] new-pos [COLOR=#0000ff]AS INT[/COLOR].
[COLOR=#0000ff]DEF VAR[/COLOR] cc [COLOR=#0000ff]AS INT[/COLOR].
[COLOR=#0000ff]DEF BUFFER[/COLOR] btemp-table-1 [COLOR=#0000ff]FOR [/COLOR]temp-table-1.

[COLOR=#0000ff]DO [/COLOR]cc = 1 [COLOR=#0000ff]TO [/COLOR]browse-name:[COLOR=#0000ff]NUM-COLUMNS[/COLOR]:
    new-pos = cc.
    [COLOR=#0000ff]FIND FIRST [/COLOR]temp-table-2
        [COLOR=#0000ff]WHERE[/COLOR] temp-table-2.col-order [COLOR=#0000ff]EQ[/COLOR] cc [COLOR=#0000ff]NO-ERROR[/COLOR].
    [COLOR=#0000ff]IF NOT AVAILABLE [/COLOR]temp-table-2 [COLOR=#0000ff]THEN NEXT[/COLOR].
    [COLOR=#0000ff]FIND FIRST [/COLOR]temp-table-1
        [COLOR=#0000ff]WHERE[/COLOR] temp-table-1.col-name [COLOR=#0000ff]EQ[/COLOR] temp-table-2.col-name [COLOR=#0000ff]NO-ERROR[/COLOR].
    old-pos = temp-table-1.col-order.
    [COLOR=#0000ff]IF[/COLOR] temp-table-1.col-order [COLOR=#0000ff]EQ [/COLOR]temp-table-2.col-order [COLOR=#0000ff]THEN NEXT.
[/COLOR][COLOR=#0000ff]    IF [/COLOR]temp-table-1.col-order [COLOR=#0000ff]NE [/COLOR]temp-table-2.col-order [COLOR=#0000ff]THEN DO[/COLOR]:
        [COLOR=#0000ff]BROWSE [/COLOR]browse-name:[COLOR=#0000ff]MOVE-COLUMN[/COLOR](old-pos,new-pos).
        [COLOR=#0000ff]FOR EACH [/COLOR]btemp-table-1
            [COLOR=#0000ff]WHERE[/COLOR] btemp-table-1.col-order [COLOR=#0000ff]GE[/COLOR] new-pos
            [COLOR=#0000ff]USE-INDEX [/COLOR]order-ndx:
            [COLOR=#0000ff]IF[/COLOR] btemp-table-1.moved [COLOR=#0000ff]EQ[/COLOR] 1 [COLOR=#0000ff]THEN NEXT.
[/COLOR]            [COLOR=#0000ff]IF [/COLOR]btemp-table-1.col-order [COLOR=#0000ff]GE [/COLOR]old-pos [COLOR=#0000ff]THEN LEAVE[/COLOR].
            [COLOR=#0000ff]IF [/COLOR]btemp-table-1.col-order [COLOR=#0000ff]EQ [/COLOR]browse-name:[COLOR=#0000ff]NUM-COLUMNS [/COLOR][COLOR=#0000ff]THEN LEAVE[/COLOR].
            btemp-table-1.col-order = btemp-table-1.col-order + 1.
            btemp-table-1.moved = 1.
        [COLOR=#0000ff]END[/COLOR].
        temp-table-1.col-order = temp-table-2.col-order.
    [COLOR=#0000ff]END.
    FOR EACH [/COLOR]temp-table-1:
        temp-table-1.moved = 0.[COLOR=#0000ff]
    END.
END.

EMPTY TEMP-TABLE [/COLOR]temp-table-2[COLOR=#0000ff].

END PROCEDURE.

[/COLOR]
 
Back
Top