Programming Guide : Working with Arrays, Table Fields, and Collections : Table Field Operations : How You Can Enable and Disable User Modifications to Table Field Data
 
Share this page          
How You Can Enable and Disable User Modifications to Table Field Data
You can modify data by doing the following:
Updating existing data in a table field row
Inserting new rows before existing rows
Deleting rows
Appending rows to the end of the table field
The following sections describe these operations in more detail.
How You Can Update Existing Data in a Table Field Row
The CurBias attribute of a field in the table field determines whether a user can directly edit that field. A field can be edited if its CurBias is FB_CHANGEABLE. The CurBias of the field is determined by the CurMode of the frame and the biases of the table field, column fields, and protofield fields.
You can use the Property Inspector to initialize the biases for each column of a table field and for the table field itself. By default, when you create a table field, the bias is FB_CHANGEABLE for each frame mode except FM_READ. The default bias for the FM_READ mode is FB_LANDABLE.
Biases can be dynamically changed in OpenROAD by using the CurBias, UpdateBias, QueryBias, ReadBias, User1Bias, User2Bias, User3Bias, or AllBias attributes of FormField objects. For more information about biases and frame modes, see Creating Dynamic Frames.
You can disable updates to the whole frame by setting CurMode to FM_READ. You can disable updates to the entire table field by setting the table field's bias to be a bias other than FB_CHANGEABLE. Or you could keep the table field's bias as FB_CHANGEABLE, and restrict a particular column by setting its bias to a bias other than FB_CHANGEABLE. For more information about CurBias, see the Language Reference Guide.
How You Can Insert New Rows Before Existing Rows
The user can insert rows before existing rows by using the Insert Before Current Row menu item of the table field's control button.
Enabling or disabling Inserts can be done by enabling or disabling this menu item from OpenROAD. You can use the Option Menu Editor to determine the name of an item in the control button menu. To open the Option Menu Editor from the Frame Editor, select the control button and then click Edit, OptionMenu. For example, if the table field's control button is named tblfld_controlbutton, the following code can be used to disable the menu:
field(tblfld_controlbutton.insertbefore).CurBias = MB_DISABLED;
The following table shows the menu text and menu button names for the table field control button:
Menu Text
Menu Button
Insert Before Current Row
insertbefore
Delete Current Row
deletecurrent
Delete All Rows
deleteall
Copy Table
copytable
To enable the menu, use bias MB_ENABLED instead of MB_DISABLED. To remove this item from the menu, use bias MB_INVISIBLE.
By default, the insertbefore menu item is enabled only in FM_UPDATE and FM_QUERY modes, and disabled in FM_READ, FM_USER1, FM_USER2, and FM_USER3 modes.
How You Can Delete Rows
The user can delete rows by using the Delete Current Row or Delete All Rows menu items of the table field's control button.
You can enable or disable deletions by enabling or disabling these menu items. The following code exemplifies disabling the delete menu items:
field(tblfld_controlbutton.deletecurrent).
    CurBias = MB_DISABLED;
field(tblfld_controlbutton.deleteall).
    CurBias = MB_DISABLED;
By default this menu item is enabled only in FM_UPDATE and FM_QUERY modes, and disabled in FM_READ, FM_USER1, FM_USER2, and FM_USER3 modes.
How You Can Append Rows to the End of a Table Field
The user can append a row at the end of the table field by choosing the row below the last row with data, and then directly editing it (if appending is enabled). The CurOps attribute of the table field determines whether appending is enabled.
To enable a row to be appended, the CurOps attribute is set to OP_APPEND. To disable this capability, set CurOps to OP_NONE. CurOps can be set directly, or you can use one of the following attributes:
ReadOps
UpdateOps
QueryOps
User1Ops
User2Ops
User3Ops
You can use the Property Inspector to initialize these attributes. Also, they can be changed dynamically in 4GL.
The following settings determine whether a user can append rows to a table field:
OP_APPEND
Specifies that the user can append rows to the end of the array by moving the cursor past the last row displayed in the table field
OP_NONE
Specifies that the user cannot append rows to the end of the array by moving the cursor past the last row displayed in the table field
OP_APPENDINSERT
Specifies that the user can append or insert rows to the table field
OP_APPENEDDELETE
Specifies automatic append at the end of the table field and that the user can delete rows
OP_APPENDINSERTDELETE
Specifies that the user can perform all operations on the table field
The setting that you specify with these attributes occurs only when the frame is in the corresponding mode. For example, if you set the QueryOps attribute while the frame is in Read mode, the QueryOps setting does not take effect until the frame is displayed in Query mode.
To change the setting immediately, regardless of the frame's mode, use the CurOps attribute of the TableField system class. This attribute accepts the same two settings as do the other operations attributes.
OpenROAD changes the operation setting for the current mode of the frame to the setting specified for the CurOps attribute. For example, if a frame is in Update mode and you set CurOps to OP_APPEND, then OpenROAD automatically sets the UpdateOps attribute to OP_APPEND also.