peDbGridType - cWebList

Determines how data is loaded in a data aware grid

Type: Property (Web Property)

Access: Read/Write

Data Type: Integer

Parameters: None

Syntax
 { WebProperty=Client }
 Property Integer peDbGridType

Web Property Read Access: WebGet peDbGridType to IntegerVariable
Web Property Write Access: WebSet peDbGridType to IntegerVariable/Value

Read Access: Get peDbGridType to IntegerVariable
Write Access: Set peDbGridType to IntegerVariable/Value


Description

This is a design-time only property.

Valid values are:

ConstantMeaning
gtAutomaticRow data are read from the server data dictionary and sent to the client in pages of a fixed number of rows. When the client needs more rows it will request further pages of row data.
gtAllDataAll possible row data are read from the server data dictionary and sent to the client when the grid is first loaded. The client will not make further requests for row data.
gtManualRow data is generated by implementing OnManualLoadData when the grid is first loaded. The client will not make further requests for row data.

The default value is gtAutomatic.

Load Time vs. Scrollbar Behaviour

When peDbGridType = gtAutomatic, the time required to load rows into a grid and be ready to interact with the user is constant with respect to the total number of rows that can potentially be loaded, i.e. this setting is more efficient for grids that will display many rows. The disadvantage with this setting is that the grid does not initially know how many rows can potentially be loaded (unless this number is less than the page size). That will mean that the grid's scroll bar rendering and behaviour will not be accurate.

When peDbGridType = gtAllData, the time required to load a grid will increase linearly with the total number of rows. However, since the total number of rows is known, scroll bar rendering and behaviour will be accurate.

Special Data Loading

Grids and lists support a special mode where the row data can be loaded manually (via OnManualLoadData), however once loaded, the grid will behave like a data-aware-grid, i.e. it will utilize a Server DataDictionary object to handle any interactions with the database.

To implement such a grid, set pbDataAware to True, set peDbGridType to gtManual and implement OnManualLoadData to generate the grid's row data.

You must generate the row data in a specific format so that it matches the data bindings (Entry_Item) in each of the grid columns. The RowID member of the row data must match database RowIDs of the server data dictionary's Main_File.

The example below demonstrates a view with a data-aware grid that is manually loaded.

Object oManualDataAwareGrid is a cWebView
    Set piWidth to 400    

    Object oVendor_DD is a Vendor_DataDictionary
    End_Object 

    Object oInvt_DD is a Invt_DataDictionary
        Set DDO_Server To oVendor_DD
    End_Object 

    Set Main_DD To oInvt_DD
    Set Server  To oInvt_DD

    Object oGrid is a cWebGrid 
        Set piHeight to 500
        Set pbColumnSortable to True
        Set peDbGridType to gtManual
        
        Object oInvt_Description is a cWebColumn
            Entry_Item Invt.Description
            Set psCaption to "Inventory Item"
            Set piWidth to 75            
            Set pbSortable to True
        End_Object
        
        Object oVendor_Name is a cWebColumn
            Entry_Item Vendor.Name
            Set psCaption to "Vendor"
            Set piWidth to 50
            Set pbSortable to True
        End_Object
        
        Object oInvt_On_Hand is a cWebColumn
            Entry_Item Invt.On_Hand
            Set psCaption to "On Hand"
            Set piWidth to 20
            Set pbSortable to True
        End_Object

        Object oInvt_Unit_Price is a cWebColumn
            Entry_Item Invt.Unit_Price
            Set psCaption to "Unit Price"
            Set piWidth to 30
            Set pbSortable to True
        End_Object

        Procedure OnManualLoadData tWebRow[] ByRef aTheRows String ByRef sCurrentRowID aTheGroups ByRef tWebGroupHeader[][][] ByRef aTheGroupHeaders
            // Loads only the first 10 inventory items.
            Handle hoDD
            RowID riRowID 
            String sRowID
            Integer iRow

            // Establish the find ordering and find the first record.
            Move 0 to iRow            
            Get Server to hoDD
            Get ReadDDFirstRecord hoDD 1 False to riRowID

            //  Find remaining records....
            While (Found and (iRow < 10))
                // We use the LoadGridRow function to fill the row struct
                // based on the DEO values
                Get LoadGridRow to aTheRows[iRow]
                
                Increment iRow
                Send Locate_Next to hoDD
            Loop
            
            // Set the first row to be the selected row
            If (IsNullRowID(riRowID)) Begin
                Move "" to sCurrentRowID
            End
            Else Begin
                Send FindByRowId of oInvt_DD Invt.File_Number riRowID
                Move (SerializeRowID(riRowID)) to sCurrentRowID
            End
        End_Procedure

        Procedure OnLoad
            Send GridRefresh
        End_Procedure
    End_Object
End_Object

For more information, see OnManualLoadData.

Sorting Behavior

peDbGridType = gtAutomatic

The grid can be sorted on any column whose data binding is to an indexed database column.

peDbGridType = gtAllData or gtManual

The grid can be sorted on every column, column sorting (i.e. user-initiated column sorting via header clicks) will be performed entirely on the client by sorting according to the data in the clicked column. The sort order will be based only on that single column, not based on multiple columns as you would be able to do with a multi-segment index and peDbGridType = gtAutomatic.

In this case, Ordering, piDefaultIndex, DefaultIndex and IndexOrder are not called.

You can use piSortColumn and pbReverseOrdering to tell the client on which column it should sort. If a column contains equal values, it will sort those equals on the data in the first column, then the second and so on. The JavaScript engine doesn't know anything about the collating sequence. For text fields (char, varchar, text, etc.), it uses the JavaScript localCompare function that sorts according to the 'language settings of the browser'.


Note

The peDbGridType setting is only relevant if the grid's pbDataAware property is True, i.e. peDbGridType is ignored in a non-data-aware grid.


About Web Properties
Each web property maintains two values: The regular property value is set during object creation and should not be changed during the lifetime of that object. To access that value, use the standard property Get and Set syntax.
The web property value is the local value stored at each client. This is synchronized to the client's local value whenever a server call is being processed. To access the web property value, use the WebGet and WebSet syntax above instead of the standard Get and Set syntax.