Internal procedures and functions
- Last Updated: January 17, 2024
- 3 minute read
- OpenEdge
- Version 12.8
- Documentation
Internal procedures and functions
The CreateRow event
handler, BindSCreateRow, gets the BufferName from
the CreateRowEventArgs class instance.
Before attempting to create the new record, the handler ensures
that the Created property is FALSE.
The handler calls the CreateRow function, which
returns zero if the create operation fails. If the create operation
succeeds, the handler adds the new record to the result list for
the appropriate query in the ProBindingSource. Finally, the handler
sets the Created property to TRUE to
signal the creation succeeded.
|
The CancelCreateRow event
handler, BindSCancelCreateRow, gets the BufferName from the CancelCreateRowEventArgs class
instance. The handler finds the correct query in the ProBindingSource
with the GetCurrentQuery function. Then, the handler
deletes the record from the appropriate temp-table, raising a warning
message if the record cannot be deleted.
|
The grid's BeforeRowUpdate event
fires when an action occurs that should result in any changed screen
values being written to the data source object. However, the event
does not indicate that the screen values have in fact changed. So,
the sample procedure needs to verify that there are changes and
then write those changes to the ProDataSet.
In the UltraGrid,
each row belongs to a band which represents a specific level in
the hierarchical grid. The event handler, gridBeforeRowUpdate,
determines the correct buffer name for a row by retrieving the UltraGridBand class' Key property.
The handler uses the RowModified property
to verify that the current row in the ProBindingSource is being
edited. The handler then uses the ASSIGN( ) method
to update the ProDataSet, raising an error if it fails. The handler
calls the ProcessRowChanges function to write the
changes in the ProDataSet back to the database.
|
The grid's BeforeRowsDeleted event
fires before any rows are deleted. The BeforeRowsDeletedEventArgs class
stores the selected rows in the Rows property.
The event handler, gridBeforeRowsDeleted, determines
the number of rows from the Length property. Note
that the Rows property is a 0-based array, so the REPEAT block counts up from zero. The
handler then calls the DeleteRow function to delete
each row in turn.
To refresh the grid properly, the handler
turns off the ProBindingSource's AutoSync property
at the start. If only a single row is deleted, the handler removes
that row directly from the current query's result list. Otherwise,
the handler reopens the query. The handler then reactivates the AutoSync property
before leaving.
|
The ProcessRowChanges function
uses the ProDataSet SAVE-ROW-CHANGES( ) and ACCEPT-ROW-CHANGES( ) methods
to write the changes from the ProDataSet back to the database.
|
The CreateRow function creates
a new record in the appropriate temp-table and sets some initial
properties. Note the use of the CATCH block
here. The ProBindingSource ensures that the parent record is in
the buffer by this point. So, the function uses the structured error
handlings approach.
The code output will look similar to the following example.
|
For more information on CATCH blocks
and structured error handling, see the section on error handling
enhancements in OpenEdge Getting Started:
New and Revised Features.
The DeleteRow function
finds the cell in the input UltraGridRow that corresponds
to the primary index for each of the temp-tables in the ProDataSet.
Using that cell's value, the function finds the ROWID for
the passed in row. The handler then repositions to that row and
deletes the row from the temp-table. The handler then calls the ProcessRowChanges function
to write the changes from the ProDataSet to the database.
|
The GetCurrentQuery function
determines the correct query to use in the ProBindingSource.
|