Consultor Eletrônico



Kbase 16714: How to Reposition to a Particular Record of a SmartQuery
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
How to Reposition to a Particular Record of a SmartQuery

INTRODUCTION
============
This knowledgebase entry demonstrates one way to reposition
a SmartQuery to a particular record based on input from an
end user at runtime.

EXAMPLE
=======
The SmartWindow application for this example contains the
following:

- SmartQuery for each customer
- SmartViewer linked to the SmartQuery
- Navigation SmartPanel to navigate through the customer
records of the SmartQuery
- A fill-in field called custnum-search and a button labeled
Search which will allow the user running the application to
enter a customer and choose the search button to have the
SmartQuery reposition to the customer that has been entered in
the fill-in and also have that customer display in the
SmartViewer

You need to add the following code to your SmartObjects to get
the above functionality:

1) Create a choose trigger for the search button on the
SmartWindow which contains the following code:

RUN set-attribute-list IN h_q-cust
("CUST-SEARCH = " + custnum-search:SCREEN-VALUE).
RUN dispatch IN h_q-cust ('search-proc':U).

When the search button is chosen this code sets an attribute in
the SmartQuery with the customer number that the user has entered
in the fill-in field. It then runs an internal procedure called
search-proc in the SmartQuery which actually does the
reposition.

2) Create an internal procedure in the SmartQuery called
search-proc which contains the following code:

DEFINE BUFFER cust-buff FOR customer.

RUN get-attribute("CUST-SEARCH").
FIND FIRST cust-buff where
cust-buff.cust-num = INTEGER(RETURN-VALUE) NO-LOCK NO-ERROR.
IF AVAILABLE cust-buff THEN DO:
REPOSITION Query-Main TO ROWID ROWID(cust-buff).
RUN dispatch in THIS-PROCEDURE ('get-next':U).
RUN notify in THIS-PROCEDURE ('row-changed, record-target':U).
END.

When this internal procedure is run from the SmartQuery it gets
the attribute which was set by the SmartWindow and finds the
appropriate customer and repositions to that customer record
within the query with the rowid. It then runs notify that the
record has changed to all the record-targets of the SmartQuery (in
this case it would be the customer SmartViewer) so that those
objects will show the new record.

With the above example, if a user enters 10 in the fill-in and
chooses the search button, customer 10 (Just Joggers Limited in
sports db) displays in the SmartViewer instead of the customer
that originally displayed. The user can then choose next from the
Navigation SmartPanel and since the SmartQuery has been
repositioned Customer 11 will display in the SmartViewer.

REFERENCES TO WRITTEN DOCUMENTATION
===================================
Progress Version 8 Users Interface Builder Developer's Guide


Progress Software Technical Support Note # 16714