User Tools

Site Tools


how_to_display_the_sort_field_first_on_a_multi_key_browse.htm
Navigation:  How To's and Troubleshooting > How to… >====== How to Display the Sort Field First on a Multi-Key Browse ====== Previous pageReturn to chapter overviewNext page

NewC7.jpg

Clarion's Browse Wizard generates multi-key browses for files with multiple keys. To see records in a different sort order, the user simply selects a tab with a different key. However, when switching to a new sort order, the sort column does not automatically appear as the first (or leftmost) column in the list box. This example uses the embed points from the Clarion (Compatibility) Templates.

To dynamically shift the sort column to the leftmost position in the list box, follow these steps:

1.Find the FORMAT string for the affected list box and copy it to the clipboard.

In the Application Tree dialog, DOUBLE-CLICK on your browse procedure.

In the Procedure Properties dialog, select the Window tab, and press the Edit as Text button.

On the LIST control declaration statement, highlight the entire FORMAT attribute parameter and choose Edit C6H0013.jpg Copy to copy it to the clipboard.

Press the Discard button to close without saving.

2.Paste the FORMAT string into the “Control Event Handling, before generated code; ?CurrentTab; NewSelection” embed point of the Browse procedure.

From the Application Tree, press the Embeds button.

In the Embeds Tree, DOUBLE-CLICK on the “Control Event Handling, before generated code; ?CurrentTab; NewSelection” embed point.

Choose SOURCE from the Select embed type dialog.

When the Text Editor opens, choose Edit C6H0013.jpg Paste.

3.“Chop up” the FORMAT string so there is only one list box column definition per line.

Each column definition begins with the width of the column immediately followed by a justification letter (L, R, C, or D). If necessary, you can get the widths and justification for each column from the List Box Formatter.

On each line you need to add enclosing single quotes.

On each line except the last, you need to add a trailing ampersand ( & ) and pipe ( | ). The ampersand is the concatenation operator, and the pipe is the line continuation character.

Your code should look something like this:

 '16L|M~Cust Number~@N4@'     & |

 '80L|M~Last Name~@S20@'      & |

 '80L|M~First Name~@S20@'     & |

 '12L|M~Area Code~@S3@'       & |

 '32L|M~Phone Number~@S8@'    & |

 32L|M~Description~@S8@'

4.Add explicit QUEUE field numbers to each list box column definition.

Queue numbers are integer constants surrounded by pound ( # ) signs. The QUEUE field numbers start with 1 and continue in ascending sequence. Your code should now look something like this:

 '16L|M~Cust Number~@N4@#1#'     & |

 '80L|M~Last Name~@S20@#2#'      & |

 '80L|M~First Name~@S20@#3#'     & |

 '12L|M~Area Code~@S3@#4#'       & |

 '32L|M~Phone Number~@S8@#5#'    & |

 '32L|M~Description~@S8@#6#'

5.Add a CASE structure and property assignment to the embedded source code.

Type ?BROWSE:1{PROP:Format}= before the first column definition. This creates the assignment statement that formats the list box at run time.

Add a CASE CHOICE(?CurrentTab) statement before the first column definition.

Add an OF 1 statement before the first column definition.

Your code should now look something like this:

CASE CHOICE(?CurrentTab)

OF 1   !Tab1, sorted by Cust Number

 ?BROWSE:1{PROP:FORMAT} ='16L|M~Cust Number~@N4@#1#'     & |

                         '80L|M~Last Name~@S20@#2#'      & |

                         '80L|M~First Name~@S20@#3#'     & |

                         '12L|M~Area Code~@S3@#4#'       & |

                         '32L|M~Phone Number~@S8@#5#'    & |

                         '32L|M~Description~@S8@#6#'

6.Duplicate the FORMAT string, with the sort column first, for each OF in the CASE.

You should have a separate OF clause for each tab (sort key) in the browse. Cut and Paste the FORMAT string for each OF assignment so that the columns appear in the sequence you want them.

Your code should now look something like this:

CASE CHOICE(?CurrentTab)

OF 1             !Tab1, sorted by Cust Number

 ?BROWSE:1{PROP:FORMAT} ='16L|M~Cust Number~@N4@#1#'     & |

                         '80L|M~Last Name~@S20@#2#'      & |

                         '80L|M~First Name~@S20@#3#'     & |

                         '12L|M~Area Code~@S3@#4#'       & |

                         '32L|M~Phone Number~@S8@#5#'    & |

                         '32L|M~Description~@S8@#6#'

OF 2             !Tab2, sorted by Last Name

 ?BROWSE:1{PROP:FORMAT} ='80L|M~Last Name~@S20@#2#'      & |

                         '80L|M~First Name~@S20@#3#'     & |

                         '16L|M~Cust Number~@N4@#1#'     & |

                         '12L|M~Area Code~@S3@#4#'       & |

                         '32L|M~Phone Number~@S8@#5#'    & |

                         '32L|M~Description~@S8@#6#'

END

In this example, notice that when the user selects tab 2, QUEUE field number #2# becomes the first column in the FORMAT string, and will be the leftmost column in the list box!

7.Save and Close the Text Editor and save your changes.

how_to_display_the_sort_field_first_on_a_multi_key_browse.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1