Consultor Eletrônico



Kbase 16512: Examples of Using the Option SmartPanel
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
Examples of Using the Option SmartPanel

INTRODUCTION
============
This knowledgebase entry discusses different ways that the Option
SmartPanel can be used in a SmartObject application.

SORTING WITH THE OPTION SMARTPANEL
==================================
The default behavior of the Option SmartPanel is for sorting a
SmartBrowser or SmartQuery at runtime. In order to link the
Option SmartPanel to a SmartBrowser or SmartQuery you need to
configure the SmartBrowser or SmartQuery as in the following
example:

1) Create a SmartBrowser for the Customer table with Cust-Num,
Name, City, and Salesrep as fields displayed in the browser.

2) Go to the XFTR - Advanced Query Options from the Section
Editor List Button in the UIB.

3) In the sort options add the sort cases that you'd like
the user to be able to choose with the Option SmartPanel
at runtime.

- Choose Insert Case
- Select Name and choose Add button then choose OK button
- Choose Insert Case again
- Select City and choose Add button then choose OK button
- Choose OK to get out of the Advanced Query Options and
save the SmartBrowser

4) You may choose one of those sort cases as the initial sort
option by choosing Initial Sort Case toggle for that sort
case.

At run time, this sort option will be the selection option
when the application is intially started. Note that this
does not work in 8.1A, the sort case chosen as the initial
case will not be selected at runtime. This problem should
be resolved for 8.2A. In order to workaround the problem in
8.1A you may add the following to a local-initialize
procedure:

RUN set-attribute-list("SortBy-Case = City").

This will make the City sort case the initial sort case in
the Option SmartPanel at runtime.

5) Place the SmartBrowser onto a SmartWindow.

6) Place an instance of the Option SmartPanel (p-option.r)
onto the SmartWindow and keep the defaults for the instance
attributes.

7) You will then be prompted by the Link Advisor to link
the Option Panel to the SmartBrowser. Choose OK to Add
the link.

8) Run the SmartWindow. The Option SmartPanel is a Selection
List which contains Name and City. You can now choose
Name or City as a Sort By option to sort the SmartBrowser by
Customer Name or by Customer City at runtime.

CHOICES WITH THE OPTION SMARTPANEL
==================================
The Option SmartPanel can also be used to allow the user to make
any choices, not just sorting options. This can be done by setting
attributes in the target object that will then be used to create
the Option Panel.

The following example describes how to use the Option SmartPanel to
allow a user to choose a Salesrep for the Customer.Salesrep field in
a Customer table SmartViewer:

1) Create a SmartQuery for Customer table.

2) Create a SmartViewer for Customer table with Name, Address,
City, State, Postal-Code, and Sales-Rep as fields.

3) Create a local adm-initialize procedure in the SmartViewer and
add the following code after the dispatch of the standard
ADM method:

DEFINE VARIABLE replist AS CHARACTER INITIAL " ".

/* Create a comma delimited list of Salesreps from
Salesrep table that can be chosen by the user */
FOR EACH Salesrep NO-LOCK:
IF replist = " " THEN replist = '"' + Salesrep.Sales-Rep.
ELSE replist = replist + "," + Salesrep.Sales-Rep.
END.
replist = replist + '"'.

/* Set attribute which will be used by Option Panel
for the choices available to the user */
RUN set-attribute-list("Rep-Options = " + replist).

/* An initial value for the Option Panel could also
be set here - you could do the following:

RUN set-attribute-list("Rep-Case = HXM"). */

4) Create a local internal procedure called Change-Salesrep
and add the following code:

/* Get the value of the option the user has chosen */
RUN get-attribute ('Rep-Case':U).

/* Assign the Customer Salesrep from the option chosen by
the user */
IF RETURN-VALUE <> " " AND RETURN-VALUE <> ? THEN
ASSIGN Customer.Sales-Rep:SCREEN-VALUE IN FRAME {&FRAME-NAME} =
RETURN-VALUE.

END PROCEDURE.

5) Create a SmartWindow. Place instances of the SmartViewer and
SmartQuery create above onto the SmartWindow and link them
together with a Record link.

6) Place an instance of the Option SmartPanel onto the
SmartWindow and change the following Instance Attributes:

Label - change to "Choose &Salesrep"
Link to - change to Rep-Target (this will allow the Option
Panel to be linked to the SmartViewer)
Ask for Valid Options in - change to Rep-Options (this is the
attribute set in the SmartViewer that contains the
Options for the choice)
Set Option Case in - change to Rep-Case (this attribute
contains the currently selected value then used
to populate the Customer.Salesrep in the
SmartViewer, this is also the initial value of
the Option Panel)
Additionally Dispatch - change to Change-Salesrep (this is the
event that is fired when the user changes the
value of the Option Panel at runtime)

7) Add the following link to the SmartWindow:

Source - Option Panel
Link Type - Rep
Target - SmartViewer

You will get a message that the viewer is not configured to
be a target for Rep. Choose to continue and link them anyway.
The Option Panel will still work with the Viewer, this
message only appears because the viewer template has not
been setup to be a Rep-Target. In order to have the Link
Advisor recognize the SmartViewer as a Rep-Tartget, you must
create a new SmartViewer template and make Rep-Target a
Supported SmartLink.

8) Add an Update SmartPanel to the SmartWindow and link it to
the SmartViewer.

9) Add a Navigation SmartPanel to the SmartWindow and link it to
the SmartQuery.

10) Run the SmartWindow. The Option SmartPanel is a Selection
List of Salesreps from the Salesrep table. You are able to
choose a Salesrep from the Selection List which then
changes the value of the Customer Salesrep in the viewer to
the value chosen in the Selection List.

REFERENCES TO WRITTEN DOCUMENTATION
===================================
Progress Version 8.1A User Interface Builder Developer's Guide


Progress Software Technical Support Note # 16512