JavaScript Editor js editor     Web development 



Main Page

When you design a form based primarily on server data, take a minimalist approach for the best performance. Determine the data and functionality needed, and delay asking the server for this data and functionality until requested by the user. Requesting data from the server uses processing time and creates network traffic. To request less data in your forms:

Storing Lookup Tables Locally

Often, an application contains several forms that use the same remote table. If the data in the table doesn't change frequently, you can speed up form loading and reduce server load using one of the following techniques:

  • Store tables that never change and aren't too large (such as the names and abbreviations of the regions or states in your country) in the local Visual FoxPro application database. If the table is joined in queries or views with remote tables, you should also keep a copy of it on the server to avoid joining local and remote data.

  • Store tables that rarely change (such as a list of company buildings) both on the server and in the local application database. Provide a way for the user to download the table when the data does change.

  • Store tables that change occasionally but not daily (such as a list of employees in a small company or department) both on the server and in the local application database. Your application should automatically refresh the local version each time it starts. This method uses extra time when the application starts, but speeds up queries when the application is running.

Displaying Fields Only On Request

Display fields that take a long time to retrieve data from the server, such as Memo or General fields, only when requested. You can use the following techniques:

  • If your form is based on a view, place Memo or General fields off screen on another form page. Add a label to the form, such as "Page down to see notes and pictures," that informs the user how to display the information. Set the FetchMemo property on the view or cursor to false (.F.), so that Visual FoxPro doesn't retrieve Memo or General fields until they're displayed on screen.

  • Set the Visible property to false (.F.) for controls bound to Memo or General fields. Add a toggle button or command button that sets the property to true (.T.), so that the user can choose to view the contents of these controls.

  • Display the most important fields on a main form, and provide a button labeled "More Information" that opens another form containing other fields. Base the second form on a view that's parameterized by the primary key field on the main form. For example, suppose you have a main form based on a view whose SQL SELECT statement includes the following code:

    В Copy Code
    SELECT customer_id, company_name, address, city, region, country
    FROM customers
    In the preceding form, cust_id is bound to thisform.txtCust_id. You could base the second form on the following view, which is used only when the user chooses the "More Information" button:

    В Copy Code
    SELECT orders.order_id, orders.order_date, orders.shipper_id, ;
       employee.emp_id, employee.last_name, employee.first_name ;
    FROM orders, employee ;
    WHERE orders.cust_id = ?THISFORM.txtCust_id ;
    AND orders.employee_id = employees.emp_id

See Also



JavaScript Editor js editor     Web development