Is SaveChanges method supposed to work on a GroupAssign linked viewer
 
Forums / SmartComponent Library - Developer Forum / Is SaveChanges method supposed to work on a GroupAssign linked viewer

Is SaveChanges method supposed to work on a GroupAssign linked viewer

4 posts, 0 answered
  1. Carl Verbiest
    Carl Verbiest avatar
    67 posts
    Registered:
    12 Oct 2018
    04 Jan 2019
    Link to this post
    We have a keydownhandler on our form to detect a return key and invoke save changes.

    It does this by finding the first container of the activecontrol that has the Consultingwerk.SmartComponents.Interfaces.ISmartTableIOTarget interface , see code snippet at the end of this post.

    it then invokes SaveChanges on the oHasSave object.
    This does not work if the viewer containing the activecontrol is a GroupAssign Target .

    In that case the savechanges stops on line 3724 of the SmartViewerControl
            IF VALID-OBJECT(oSmartGroupAssignSource) THEN
                RETURN.

    Is this the way it's supposed to work ?
    I guess the return is there to prevent an endless recursion when the savechanges is called by the groupassign source, but should this also be the case when called directly on the group assign target ?


            /* get extra info about the active control */
            oContainer = this-object . // the form control
            FindControls:
            do while valid-object (oContainer):
                oControl = oContainer:ActiveControl .
                if valid-object (oControl) and type-of (oControl, System.Windows.Forms.ContainerControl)
                then oContainer = cast (oControl, System.Windows.Forms.ContainerControl) .
                else leave FindControls.

    ..
                /* get extra info for tableIO */
                if type-of (oControl, Consultingwerk.SmartComponents.Interfaces.ISmartTableIOTarget)
                then oHasSave = cast (oControl, Consultingwerk.SmartComponents.Interfaces.ISmartTableIOTarget).
            end.

     
    Last modified on 04 Jan 2019 15:01 by Carl Verbiest
  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    04 Jan 2019 in reply to Carl Verbiest
    Link to this post
    Hi Carl,

    I suggest your code would check the SmartGroupAssignSource property of the viewer too and if that's set call SaveChanges there.

    Cheers,
    Mike
  3. Carl Verbiest
    Carl Verbiest avatar
    67 posts
    Registered:
    12 Oct 2018
    04 Jan 2019 in reply to Mike Fechner
    Link to this post
    Hi Mike,

    I added following code after the current code.

    I tested this and it works but I'm a bit worried about the final cast to Consultingwerk.SmartComponents.Interfaces.ISmartTableIOTarget.

    Are there SmartGroupAssignSource's possible that do not implement the ISmartTableIOTarget interface ?

                do while type-of(oHasSave, Consultingwerk.SmartComponents.Interfaces.ISmartGroupAssignTarget)
                    and valid-object(cast(oHasSave, Consultingwerk.SmartComponents.Interfaces.ISmartGroupAssignTarget):SmartGroupAssignSource)
                :
                        oHasSave = cast(
                            cast(oHasSave, Consultingwerk.SmartComponents.Interfaces.ISmartGroupAssignTarget):SmartGroupAssignSource,
                            Consultingwerk.SmartComponents.Interfaces.ISmartTableIOTarget).
                end.
     
  4. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    04 Jan 2019 in reply to Carl Verbiest
    Link to this post
    It's implemented by the SmartViewerControl and the SmartUpdatableBrowser. So I'm not seeing any issue there.

    But to be safe, do a TYPE-OF before the CAST.
4 posts, 0 answered