Navigation:  Classes > bBrowser >

bBrowser:Use()

Print this Topic    Previous pageReturn to chapter overviewNext page

Purpose

Links a server to the browser.

Class

bBrowser

Type

Method

Syntax

<oBrowser>:Use(

[<oServer>],

[<auField>],

[<auFieldOpen>],

[<auFormat>]

) Æ lSuccess

Arguments

<oServer>The server that is to be linked to the browser. If the browser is already linked to a server, this connection is removed. If this argument is not specified, any existing connection to a server already linked is removed. In this case, the remaining arguments are not considered.
Data type:Object

 

<auField>An array with fields that the browser is to support. The array can contain both field numbers and field names (string or symbol). If this argument is not specified, all fields of the server are included.
Data type:Array

 

<auFieldOpen>An array with fields that are to be opened and shown in the browser automatically. The array can contain both field numbers and field names (string or symbol). If this argument is not specified, all supported fields (see argument <auField>) are shown. If an empty array {} is specified, no columns are shown. The only fields are permitted are those defined by the argument <auField>.
Data type:Array

 

<auFormat>An array for formatting the columns. If this argument is specified, the method bBrowser:FormatColumns() is called with this argument. The argument is described in the method bBrowser:FormatColumns().
Data type:Array

Return Value

lSuccessA logical value that indicates whether the server was linked with the browser.
TRUEThe server was linked.
FALSEThe server could not be linked.
Data type:Logic

Description

bBrowser:Use() links a server with the browser and registers the browser to the server with the method oServer:RegisterClient() as client of the server. Additionally, the fields of the argument <auField> create columns. If this argument was not specified, all fields of the server create columns. Subsequently, the columns of the fields of the argument <auFieldOpen> are opened and shown in the browser. If this argument was not specified, all columns are opened and shown. If no columns are to be opened, an empty array ( {} ) must to be specified in the argument <auFieldOpen>.

 

The bBrowser administers two lists. The first list defines the columns (fields) that the browser supports. The second list is a subset of the first list and defines the columns (fields) that the browser has opened (shown) and to those the user sees and in which he can navigate.

 

To optimize the access to the linked data server, the bBrowser:ServerType should be defined first. If no server type is defined, the method bBrowser:Use() tries to determine the server type by the class of the server. The following classes are recognized:

 

Class

ServerType

DBServer

#Dbase

SQLSelect

#SQL

ADOServer

#SQL

ADORecordSet

#SQL

 

If the server is to be closed automatically, as soon as the browser is destroyed or linked to a new server, the access bBrowser:AutoClose must be assigned the value TRUE.

 

Important Notes!
If the browser is already linked with a server, then all available columns are removed from the browser and destroyed with the method bBrowserColumn:Destroy(). In addition, the browser is unregistered as client of the server by calling the method oServer:UnregisterClient().

Samples

In the following sample all fields of the database 'CUSTOMER.DBF' are showed in the browser.

 

odbsCUSTOMER := DBServer{"CUSTOMER"}

oBrowser := bBrowser{oOwner,;

                                               1000,;

                                               Point{0, 0},;

                                               Dimension{300, 250}}

oBrowser:ServerType := #DBase

oBrowser:Use(odbsCUSTOMER)

oBrowser:Show()

 

In the following sample assumed that the database 'CUSTOMER.DBF' contains the fields 'ID', 'LASTNAME', 'FIRSTNAME', 'STREET', 'ZIP' and éCITY'. The database is linked to the browser whereby however only the fields 'ID', 'LASTNAME' and 'FIRSTNAME' are showed.

 

odbsCUSTOMER := DBServer{"CUSTOMER"}

IF odbsCUSTOMER:Used

       oBrowser := bBrowser{oOwner,;

                                                1000,;

                                                Point{0, 0},;

                                                Dimension{300, 250}}

       oBrowser:ServerType := #DBase

       oBrowser:Use(odbsCUSTOMER,, {#ID, #LASTNAME, #FIRSTNAME})

       oBrowser:Show()

ENDIF

 

In the following sample no columns are showed in the browser.

 

odbsCUSTOMER := DBServer{"CUSTOMER"}

IF odbsCUSTOMER:Used

       oBrowser := bBrowser{oOwner,;

                                                1000,;

                                                Point{0, 0},;

                                                Dimension{300, 250}}

       oBrowser:ServerType := #DBase

       oBrowser:Use(odbsCUSTOMER,, {})

       oBrowser:Show()

ENDIF

See Also

bBrowser:AddColumn()

bBrowser:AutoClose

bBrowser:Clear()

bBrowser:FormatColumns()

bBrowser:InitRecordScope()

bBrowser:OpenColumn()

bBrowser:Server

bBrowser:ServerType

bBrowser:Used

bBrowserColumn:Destroy()

 


Page url: http://www.YOURSERVER.com/index.html?bbrowser_use.htm