Dynamic Table

This script simulates a dynamic table on a form. You can add, delete or modify rows in the table The code below needs 5 fields ( A1, B1, C1, D1, E1 ) on the form. The field properties are : Text, Calculated In addition create 5 fields ( HA, HB, HC, HD, HE ) with properties: Text, Calculated, Always hidden Create 3 Buttons on the form ( Add Row, Delete Row, Modify Row ) Create a scipt library and copy the SCRIPT LIBRARY code Create 4...

agents and copy the AGENT code. Create a form ("Diaolog Box") with a layout region Create 5 fields in the layout region ( HA, HB, HC, HD, HE ) with properties: Text, Editable '========================================================== ' SCRIPT LIBRARY "SharedVariables" '========================================================== Option Public Option Declare Dim Session As NotesSession Dim Workspace As NotesUIWorkspace Dim DB As NotesDatabase Dim UIDoc As NotesUiDocument Dim Doc As NotesDocument Sub Initialize 'Declare global object variables Set Workspace = New NotesUIWorkspace Set Session = New NotesSession Set DB = Session.CurrentDatabase Set UIDoc = Workspace.CurrentDocument Set Doc = UIDoc.Document End Sub Sub ClearFields Call UIDoc.FieldSetText("HA","") Call UIDoc.FieldSetText("HB","") Call UIDoc.FieldSetText("HC","") Call UIDoc.FieldSetText("HD","") Call UIDoc.FieldSetText("HE","") End Sub '========================================================== ' AGENT "AddFirstRow" '========================================================== 'OPTIONS Option Public Option Declare Use "SharedVariables" 'DECLARATION Dim AField As Variant Dim BField As Variant Dim CField As Variant Dim DField As Variant Dim EField As Variant Sub Initialize Call GetCurrentFields() 'Get values of existing fields Call ClearFields() 'Initialize hidden fields If Workspace.DialogBox( "DialogBox", True,True, False, True, False,False, "Enter New Characteristic") Then Call SetTableFields End If Call UiDoc.Reload Call UiDoc.Refresh End Sub Sub GetCurrentFields AField = ExpandField(Doc.A1) BField = ExpandField(Doc.B1) CField = ExpandField(Doc.C1) DField = ExpandField(Doc.D1) EField = ExpandField(Doc.E1) End Sub Sub SetTableFields AField = Doc.HA(0) BField = Doc.HB(0) CField = Doc.HC(0) DField = Doc.HD(0) Efield = Doc.HE(0) Doc.A1 = AField Doc.B1 = BField Doc.C1 = CField Doc.D1 = DField Doc.E1 = EField End Sub Function ExpandField(Field As Variant) As Variant Dim NewField() As String 'Array to temporarily store the new "expanded" field. Dim J As Integer 'Index counter for new field Dim K As Integer 'Index counter for existing field. Redim Newfield(0) 'dimension the newfield to one element only NewField(0) = "" 'Return the expanded field. Expandfield = newfield End Function '========================================================== ' AGENT "AddRow" '========================================================== Option Public Option Declare Use "SharedVariables" Dim InsertionPoint As Integer Dim AField As Variant Dim BField As Variant Dim CField As Variant Dim DField As Variant Dim EField As Variant Sub Initialize InsertionPoint = Cint(Trim(Session.GetEnvironmentString("EnvIP"))) Call GetCurrentFields() 'Get values of existing fields Call ClearFields() 'Initialize hidden fields If Workspace.DialogBox( "DialogBox", True,True, False, True, False,False, "Enter New Characteristic") Then Call SetTableFields End If Call UiDoc.Reload Call UiDoc.Refresh End Sub Sub GetCurrentFields AField = ExpandField(Doc.A1) BField = ExpandField(Doc.B1) CField = ExpandField(Doc.C1) DField = ExpandField(Doc.D1) EField = ExpandField(Doc.E1) End Sub Sub SetTableFields 'Using InsertionPoint as an index, plug the values returned from the dialog box into the appropriate places in the respective "field" variants. AField(InsertionPoint)

This was first published in November 2000

Dig deeper on Domino Resources - Part 4

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close