Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

SRP EditTable and OI Dictionary data association

I just wanted to verify that I haven't missed anything in the documentation about the SRP EditTable concerning data association with OI dictionaries. Is there a way to associate OI dictionary fields with SRP EditTable columns/fields, or is this to be done programmatically?

Thanks,
Dan

Comments

  • Hi Dan,

    OpenInsight does not provide a way to naturally bind database columns to ActiveX controls. So you have to manage this on your own. For SRP EditTable controls, the most common approach is to keep an invisible OI edit table control on the form and then you manage the transfer of data between the OI edit table and the SRP EditTable within the form's READ and WRITE events.

    You can make this more complex if you like by syncing the data during various SRP EditTable events, such as the AfterUpdate event and LostFocus event. That way you can also take advantage of having the SAVEWARN property being set properly and making sure any dependent calculated columns are updated dynamically.

    The exciting news for us is that OpenInsight 10 is supposed to enable databinding for ActiveX controls. I do not believe this has been officially announced, but it was discussed at the last Revelation Conference.
  • Ok - thank you for clarifying that for me, and for the programming suggestions. It looks like I am running out of reasons to use the OpenInsight edit table. :-)

    Thanks,
    Dan
  • Dan,

    In case it will help you along, here is a routine that ships with FrameWorks that we use to help with this kind of management: Function Transfer_EditTable_Data(SourceEditTable, TargetEditTable, ArrayFlag, UpdateCellEdit) /*********************************************************************************************************************** This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written permission from SRP Computer Solutions, Inc. Name : Transfer_EditTable_Data Description : Transfer data from one EditTable to another. Normally this will be from an OpenInsight databound EditTable to an SRP OLE EditTable and vice-versa. Notes : This routine will typically be called from an OLE EditTable's LostFocus event and from the window's WRITE_PRE and READ_POST events. A check is first made to see if the controls are valid. If not, the function will return a failure flag. Parameters : SourceEditTable [in] -- The EditTable with the data that needs to be transferred. TargetEditTable [in] -- The EditTable that the data will be transferred in to. ArrayFlag [in] -- If the target is an OpenInsight EditTable then this flag indicates whether the ARRAY property instead of the DEFPROP property should property should not be set after the EditTable is populated. UpdateCellEdit [in] -- Flag to determine if the UpdateCellEdit method should be called before the transfer occurs. Normally only done during a window's WRITE event to make sure all in-progress changes are updated to the SRP EditTable control. If this is set during an SRP EditTable event this could cause the focus to get stuck in the control. Success [out] -- Return flag to indicate if the process was successful. History : (Date, Initials, Notes) 01/22/06 dmb Original programmer 02/16/08 dmb Add UpdateCellEdit parameter to determine if the UpdateCellEdit method should be called 07/21/08 rch Set Redraw off and on for Target OLE EditTable 07/14/10 rch Clear out databound edit table columns in @RECORD to work around OI problems 07/20/10 rch Skip copying of source data to target table if both have the same data ***********************************************************************************************************************/ $insert LOGICAL Declare function Get_Property Declare subroutine Set_Property, Send_Message Success = Yes$ ; // Assume successful for now. If Assigned(SourceEditTable) else SourceEditTable = If Assigned(TargetEditTable) else TargetEditTable = If Assigned(ArrayFlag) else ArrayFlag = No$ If ArrayFlag EQ then ArrayFlag = No$ If Assigned(UpdateCellEdit) else UpdateCellEdit = No$ If UpdateCellEdit EQ then UpdateCellEdit = No$ If Get_Property(SourceEditTable, 'HANDLE') then If Get_Property(TargetEditTable, 'HANDLE') then If Get_Property(SourceEditTable, 'OLE.ProgID') EQ 'SRP.EditTable.1' then SourceProp = 'OLE.Array' If UpdateCellEdit then Send_Message(SourceEditTable, 'OLE.UpdateCellEdit') end else If ArrayFlag EQ Yes$ then SourceProp = 'ARRAY' end else SourceProp = 'DEFPROP' end end If Get_Property(TargetEditTable, 'OLE.ProgID') EQ 'SRP.EditTable.1' then TargetProp = 'OLE.Array' If UpdateCellEdit then Send_Message(TargetEditTable, 'OLE.UpdateCellEdit') end else If ArrayFlag EQ Yes$ then TargetProp = 'ARRAY' end else TargetProp = 'DEFPROP' end end end else Success = No$ end end else Success = No$ end If Success then *Data = Get_Property(SourceEditTable, SourceProp) SourceData = Get_Property(SourceEditTable, SourceProp) TargetData = Get_Property(TargetEditTable, TargetProp) If SourceData NE TargetData then // Skip this if source and target have the same data & avoid SAVEWARN message If TargetProp NE 'OLE.Array' then // The target EditTable is an OpenInsight control. // Clear the @RECORD position values before setting its property. // Otherwise, an OI bug may result in incorrect values in some {FIELD} references when symbolics are calculated. PosValues = Get_Property(TargetEditTable, 'POS') If PosValues then NumValues = Count(PosValues, @SVM) + (PosValues NE ) For iVal = 1 to NumValues Pos = PosValues<0, 0, iVal> If Pos then @RECORD<Pos> = end Next iVal Set_Property(@Window, 'RECORD', @RECORD) end // Make sure there are enough empty rows before setting its property. // Otherwise, the data might get truncated. *NumDataRows = DCount(Data<1>, @VM) NumDataRows = DCount(SourceData<1>, @VM) Array = Get_Property(TargetEditTable, TargetProp) NumEditTableRows = DCount(Array<1>, @VM) If NumDataRows GT NumEditTableRows then NumExtraRows = NumDataRows - NumEditTableRows For i = 1 to NumExtraRows Send_Message(TargetEditTable, 'INSERT', -1, ) Next i end end else // Set Redraw to false for Target OLE EditTable control Set_Property(TargetEditTable, 'OLE.Redraw', False$) end *Set_Property(TargetEditTable, TargetProp, Data) Set_Property(TargetEditTable, TargetProp, SourceData) If TargetProp EQ 'OLE.Array' then Set_Property(TargetEditTable, 'OLE.Redraw', True$) end end end Return Success Hopefully this will save you some effort toward getting SRP EditTable controls functioning the way you want.
  • Great!

    Thank you Don!
  • Don,

    I've had this in the back of my head as a to do one day thing, just to combat the data binding objections.
    Didn't realise it was out there already.

    I use the SRP edittable whenever data binding is not a requirement and as Dan said non users are fast running out of excuses not to.

    Thanks for putting it out there for us all to see.
Sign In or Register to comment.