Data Access Worldwide Knowledge Base
Article ID 2245 Article Title EXAMPLE: Refreshing a view when it gets the focus again Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2245 KBase Category VDF12 Date Created 09/29/2006 Last Edit Date 12/14/2006
Article Text
QUESTION:
I have a program with a view in which I see particular data (say, customer information). In the same program I have a report(view) that can be used to run a report on the customer table.
When the report runs and a record is printed, I change the value of a column (let's say the customer.last_printed column). When the report is finished and I come back to my view with customer information, I would like to see the DEO for last_printed being updated with the information set while running the report.
How do I refresh this information?
ANSWER:
You can use the entering_scope method and tell the DDO to reread the information from disk into the local record buffer again. At that time the DDO will inform all its DEOs about the record change (it is the same) and the DEOs will show the value. You should only do this when the function should_save returns false or you will loose changes made in the view.
The enclosed class can be used to demonstrate this. You can use it directly (or mix the code with your own class) and see how it works. Do the following:
- Download the class
- Save the file in it the order entry example appsrc folder
- Open customer.vw
- Change the class of the view from dbView to cRefreshdbView
- Set the property pbAutoRefreshOnEntering of the view to true
- Compile the order entry example
- Open both the order and the customer view
- In the customer view find the first customer, switch to the balances tabpage.
- In the order view find the first order
- Add a detail line to the order and save
- Now click on the customer view and see the purchase value change
The above describes the situation when "pbAutoRefreshOnEntering" is set to true. The class also contains a property called "pbAutoRefreshOnTimer" that can be set to true. When this is set to true, the view will create a timer object and refreshes the contents of the view in a number of milliseconds, following the same rules about should_save. By default, this timer fires every 10 seconds but you can change this by setting the piTimeOut property.
If the time is not active, the value is stored and later used when the timer is enabled. If you want to disable the timer you can send the message EnableTimer True/False or set the property pbAutoRefreshOnTimer to false. Setting the property to false destroys the timer object while the EnableTimer just switches off the timer temporarily.
NOTE: The code is - due to the use of meta tags - only compilable under revision 12.0. With a little change you can make it work for VDF11.1 if you want.
Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu
Web Links Related to this Article
File cRefreshdbView.pkg
URL=http://www.dataaccess.com/KBasePublic/Files/2245.cRefreshdbView.pkg
Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.
The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.