Class
DBKit.Page
DBKit.Page
Description
Used to display other DBKit controls with data from the current row of a database table to which it's assigned.
Only the members declared by DBKit.Page itself are described here; for the inherited members, see the parent class.
Properties
Name |
Type |
Read-Only |
|---|---|---|
Methods
Name |
Parameters |
Returns |
|---|---|---|
theRowsSource As |
||
|
||
parentTableName As String |
||
Events
Name |
Parameters |
Returns |
|---|---|---|
error As DatabaseException |
||
error As RuntimeException |
||
row As DBKit.Row |
||
row As DBKit.Row |
||
row As DBKit.Row |
||
row As DBKit.Row |
||
row As DBKit.Row |
||
row As DBKit.Row |
||
row As DBKit.Row |
||
row As DBKit.Row |
Property descriptions
DBKit.Page.AutomaticHints
AutomaticHints As Boolean
Whether the controls on this page automatically set their Hint from the database column's display name when no Hint is set.
The default is True.
DBKit.Page.ConfirmCancelButtonCaption
ConfirmCancelButtonCaption As String
The caption of the Cancel button in the unsaved-changes confirmation dialog.
The default is "Cancel".
DBKit.Page.ConfirmContinueButtonCaption
ConfirmContinueButtonCaption As String
The caption of the Continue button in the unsaved-changes confirmation dialog.
The default is "Continue".
DBKit.Page.CurrentRow
CurrentRow As DBKit.Row
The current row of the database table this page operates on.
DBKit.Page.Database
Database As Database
The database this page operates on.
DBKit.Page.DatabaseDisconnectedMessage
DatabaseDisconnectedMessage As String
The message displayed when the layout has lost its connection to the database and DBKit cannot reconnect right away. Use <$1> as a placeholder for the application name.
The message is not displayed if the DatabaseDisconnected event returns True.
The default is "<$1> has lost its connection to the server it requires to function. You'll be notified when the connection has been reestablished."
DBKit.Page.DatabaseReconnectedMessage
DatabaseReconnectedMessage As String
The message displayed when the connection to the database has been re-established, after the DatabaseDisconnectedMessage message was displayed. Use <$1> as a placeholder for the application name.
The default is "<$1> has reestablished its connection to the server."
DBKit.Page.DeleteConfirmExplanation
DeleteConfirmExplanation As String
The explanation text of the delete confirmation dialog.
The default is "This action cannot be undone."
DBKit.Page.DeleteConfirmMessage
DeleteConfirmMessage As String
The message text of the delete confirmation dialog.
The default is "Are you sure you want to delete this record?".
DBKit.Page.DeleteConfirmTitle
DeleteConfirmTitle As String
The title of the delete confirmation dialog.
The default is "Delete Record".
DBKit.Page.OrderBy
OrderBy As String
The sort order used when loading rows from the database table.
DBKit.Page.SelectedRowIndex
SelectedRowIndex As Integer
The index of the currently selected row in the list control.
DBKit.Page.TableName
TableName As String
The name of the database table this page operates on.
DBKit.Page.TableRelationships
TableRelationships As String
The relationships between this page's table and other tables, with one relationship per line in the format childTableName.childColumnName = parentTableName.parentColumnName. Appending = viaColumnName is optional and specifies the via column, which identifies which relationship to use when the child table has more than one foreign key to the same parent table.
The child column is the foreign key. The parent column may be any column of the parent table, not only its primary key, but it should be unique, as DBKit matches the child column's values against it to find the related rows. This allows relationships to be defined on business keys, for example
invoiceline.model = inventory.model. The relationships are loaded when the page opens and are used to find related rows.If the layout contains a DBKit.Table for a table that no relationship connects to the layout's table, DBKit raises a
DBKitException: "No table relationship is defined between the [child] and [parent] tables. Define one in the TableRelationships property of the layout." The bracketed words are replaced by the names of the two tables.
DBKit.Page.UnsavedChangesExplanation
UnsavedChangesExplanation As String
The explanation text of the unsaved-changes confirmation dialog.
The default is "If you continue, your changes will not be saved.".
DBKit.Page.UnsavedChangesMessage
UnsavedChangesMessage As String
The message text of the unsaved-changes confirmation dialog.
The default is "You have unsaved changes.".
DBKit.Page.UnsavedChangesTitle
UnsavedChangesTitle As String
The title of the unsaved-changes confirmation dialog.
The default is "Unsaved Changes".
DBKit.Page.Where
Where As String
The filter used when loading rows from the database table.
Method descriptions
DBKit.Page.Constructor
Constructor(theRowsSource As DBKit.SDK.RowsListControl, createNewRow As Boolean)
Called when the page is created. Sets up the page's layout and optionally creates a new row. theRowsSource is the rows list control the page is associated with; pass Nil for none. createNewRow is True to create a new row when the page opens.
DBKit.Page.DBKitControls
DBKitControls() As DBKit.SDK.RowBase()
Returns the DBKit controls on this page.
DBKit.Page.ForeignKeyColumnName
ForeignKeyColumnName(parentTableName As String) As String
Returns the name of the foreign key column in this page's table that relates to the table parentTableName.
DBKit.Page.TableName
TableName() As String
Returns the name of the database table for this page: the TableName property if set, otherwise the page's name.
Event descriptions
DBKit.Page.DatabaseConnected
DatabaseConnected()
Raised when the database connection for this layout has been established, including after a successful reconnection.
DBKit.Page.DatabaseDisconnected
DatabaseDisconnected(error As DatabaseException) As Boolean
Raised when a database operation fails because the connection to the database was lost. error is the exception that occurred.
Reconnect to the database and return True to handle recovery yourself and have the failed query retried once. Return False, or do not implement this event, to let DBKit handle recovery itself.
DBKit.Page.Error
Error(error As RuntimeException)
The error passed to this event has occurred.
DBKit.Page.RowChanged
RowChanged(row As DBKit.Row)
The current row (passed to the event) has been changed.
DBKit.Page.RowCreated
RowCreated(row As DBKit.Row)
A new row (passed to the event) was just created and is now the current row.
DBKit.Page.RowDeleted
RowDeleted(row As DBKit.Row)
The current row (passed to the event) has been deleted.
DBKit.Page.RowEditing
RowEditing(row As DBKit.Row)
The current row (passed to the event) is being edited by the user.
DBKit.Page.RowLoaded
RowLoaded(row As DBKit.Row)
The current row (passed to the event) has been loaded.
DBKit.Page.RowNotSelected
RowNotSelected
There is no row currently selected.
DBKit.Page.RowSaved
RowSaved(row As DBKit.Row)
The current row (passed to the event) has been saved.
DBKit.Page.RowSaving
RowSaving(row As DBKit.Row)
The current row (passed to this event) is about to be saved.
DBKit.Page.RowUndone
RowUndone(row As DBKit.Row)
The changes made to the current row (passed to this event) have been undone.
Notes
Connecting the layout to a database
Add a DatabaseConnection object to your project and assign it to the Database property in the Layout Editor. That is how the layout knows which database connection to use.
When the connection is lost
If a database operation fails because the connection to the database was lost, the layout raises the DatabaseDisconnected event. A handler that reconnects to the database and returns True takes over recovery, and DBKit retries the failed query once. If the handler returns False, or the event is not implemented, DBKit tries to reconnect itself and retries the failed query if it succeeds. If DBKit cannot reconnect, it displays the DatabaseDisconnectedMessage message and disables the layout's controls. While the controls are disabled, DBKit keeps trying to reconnect. When the connection is re-established, the layout reloads its tables (the current row, any unsaved edits and the active search are preserved), re-enables the controls, displays the DatabaseReconnectedMessage message and raises the DatabaseConnected event.
A save or delete that fails because of the lost connection displays its usual error message and is not retried. The handling described above then applies.
How controls find their columns
If a control's ColumnName is blank, the control's own name is used as the column name. You only need to set ColumnName if you want a different column or cannot name the control the same as the column. If the resulting name is not a column of the layout's table, loading a row raises an exception whose message names the control and explains the correction: rename the control to the column name or set its ColumnName property.
Filtering and sorting rows
Use Where to filter which rows are loaded and OrderBy to sort them. Provide just the expression in each case, not the SQL keywords: set Where to Country = 'USA' rather than WHERE Country = 'USA', and OrderBy to LastName rather than ORDER BY LastName.
Localization
Localize the layout's user-facing text (the delete-confirmation and unsaved-changes dialog text and the confirmation button captions) the standard Xojo way: assign a dynamic constant to each property and provide translations for as many languages as you need, or localize the property values directly.
Compatibility
Project Types |
Web |
Operating Systems |
All |