Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
796 views
in Technique[技术] by (71.8m points)

openedge - Why can I sort columns in a browser?

Normally StackOverflow questions are of the form "I don't know how to do something.", but this one is of the form "I know how to do something, but I don't understand why it works.".
More exactly, I'm clicking on the title column of a browser inside a regular window, and then the MOUSE-SELECT-CLICK event is triggered, causing the corresponding column to be sorted, ascending or descending, as you can see in the following source code:

DEFINE BROWSE browser-object
  QUERY browser-object DISPLAY
    temp_table.Field1 FORMAT ... COLUMN-LABEL "Label1"    
    temp_table.Field2 FORMAT ... COLUMN-LABEL "Label2"
    ...

DEFINE VARIABLE L-logical-Field1 AS LOGICAL INITIAL TRUE.
DEFINE VARIABLE L-logical-Field2 AS LOGICAL INITIAL TRUE.
...

ON MOUSE-SELECT-CLICK OF temp_table.Field1 IN BROWSE browser-object
DO:
    IF L-logical-Field1
    THEN OPEN QUERY browser-object FOR EACH temp_table BY temp_table.Field1.
    ELSE OPEN QUERY browser-object FOR EACH temp_table BY temp_table.Field1 DESC.
    L-logical-Field1 = NOT L-logical-Field1.
END.
ON MOUSE-SELECT-CLICK OF temp_table.Field2 IN BROWSE browser-object
DO:
    IF L-logical-Field2
    THEN OPEN QUERY browser-object FOR EACH temp_table BY temp_table.Field2.
    ELSE OPEN QUERY browser-object FOR EACH temp_table BY temp_table.Field2 DESC.
    L-logical-Field2 = NOT L-logical-Field2.
END.

This is working:
When I click on the title of the column, the column gets sorted. When I click elsewhere in the column, nothing happens.

But WHY does it work? In the source code I have written what to do when I click in the column ANYWHERE, I did not specify that the title column should be clicked, but still it's working.

You can say "Yes, so what? It's working, so what's the big deal?", but I fear that later the customer might ask me to program some behaviour when the column is clicked above a certain tuple and asks me to do something with that particular tuple, and I won't have the smallest idea how to start.

Does anybody have an idea?
Thanks in advance

question from:https://stackoverflow.com/questions/65916272/why-can-i-sort-columns-in-a-browser

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To see what is being executed, you can make use of the log-manager with entry type 4glTrace.

ON ALT-CTRL-H ANYWHERE DO:

   IF LOG-MANAGER:LOGFILE-NAME = ? THEN DO:
      LOG-MANAGER:LOGFILE-NAME = "4gltrace.log".
      LOG-MANAGER:LOG-ENTRY-TYPES = "4GLTRACE:2".
      MESSAGE "Started logging. Press Ctrl+Alt+H again to stop.":u VIEW-AS ALERT-BOX.
   END.
   ELSE DO:
      LOG-MANAGER:CLOSE-LOG().
      OS-COMMAND NO-WAIT VALUE( "4gltrace.log" ).
   END.
   RETURN NO-APPLY.

END.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...