Forums

Find answers, ask questions, and connect with our
community all around the world.

Home Forum Omnis General Forum Subform Set Panel

  • Subform Set Panel

    Posted by Obonye on September 6, 2024 at 1:27 pm

    Hi $all,

    In the sample library jssubformsetpanels, there is method opensubform that opens the subform with the command “Do $cinst.$clientcommand(“subformset_add”,<b style=”background-color: var(–bb-content-background-color); font-family: inherit; font-size: inherit; color: var(–bb-body-text-color);”>lSetRow)”. How do I close this subform? I’m incorporating the code into my app (in another subform) and getting an error, subformset_add: a subformset named subformpanelsset already exists. If only I could close the subformset or refresh it.


    Martin.

    Andreas Pfeiffer replied 10 months, 2 weeks ago 2 Members · 41 Replies
  • 41 Replies
  • Andreas Pfeiffer

    Administrator
    September 6, 2024 at 1:36 pm

    Hi Martin,

    subformset_add() does not open a subform. It adds a subform set. subformset_formadd() opens a subform. That said you would need to use subformset_formremove() to remove the subform from the subformset.

    However if you prefer using those popup forms for modeless forms I would recommend subformdialogshow instead. In that case you do not need to deal with a subformset but the form is modal only. Closing such a subform can then be done using subformdialogclose.

    Best,

    Andreas

    • Obonye

      Member
      September 6, 2024 at 2:13 pm

      Hi @andreas-pfeiffer

      You have not specified the row to pass. I tried to remove the form like this,

      Do $cinst.$clientcommand(“subformset_formremove”,iSetRow)

      It does not remove the subformsets.

      Regards, Martin

      • Andreas Pfeiffer

        Administrator
        September 6, 2024 at 2:46 pm

        Martin,

        sure subformset_formremove does not remove the subformset. it is not supposed to remove the subformset. Only the subform within the set.

        If you use this command you would need to specify the subformset name and the form id as a row parameter so that subformset_formremove understands which form in within subformset to be removed.

        Best,

        Andreas

        • Obonye

          Member
          September 6, 2024 at 3:28 pm

          Calculate lSetRow as row(“SubformPanelsSet”,1)

          Do $cinst.$clientcommand(“subformset_formremove”,lSetRow)

          Calculate lSetRow as row(“SubformPanelsSet”,2)

          Do $cinst.$clientcommand(“subformset_formremove”,lSetRow)

          I have added this method in the $destruct method

          If I close the subform containing the subformpanelsset and reopen it, I still get the error, the subform set already exists. yet the formremove command is run.

          • Andreas Pfeiffer

            Administrator
            September 6, 2024 at 4:38 pm

            Martin,

            This is because closing the form does not close the subformset. You also would need to close the subformset.

            Best,

            Andreas

            • Obonye

              Member
              September 6, 2024 at 4:41 pm

              How do I close the subformset?

            • Andreas Pfeiffer

              Administrator
              September 6, 2024 at 4:44 pm

              subformset_remove

              This is documented here: https://www.omnis.net/developers/resources/onlinedocs/WebDev/02jsremoteforms.html#subform-sets-1

              Best,

              Andreas

            • Obonye

              Member
              September 6, 2024 at 5:00 pm

              The documentation reference has really helped. The command below has closed the subformset:

              Do $cinst.$clientcommand(“subformset_remove”,row(‘SubformPanelsSet’))

              Thank you.

            • Andreas Pfeiffer

              Administrator
              September 6, 2024 at 5:01 pm

              Awesome! This is great!

              Have a nice evening then.

              Best,

              Andreas

            • Obonye

              Member
              September 8, 2024 at 9:55 pm

              Hi Andreas,

              I’m back to you again on this subformpanelsset. The command

              Do $cinst.$clientcommand(“subformset_remove”,row(‘SubformPanelsSet’))

              seem to affect the $construct of the js remote form. The stack is unable to hit it after the formsets have been destructed. Do you have any insights into effects of “Do $cinst.$clientcommand(“subformset_remove”,row(‘SubformPanelsSet’))” on the $construct of a remote form assigned as a $classname of a subform object?

              Martin.

  • Andreas Pfeiffer

    Administrator
    September 9, 2024 at 6:58 am

    Hi Martin,

    Not sure what you are trying to do. Are you saying that you are executing the subformset_remove within the $construct of a form? If so, why?

    Best,

    Andreas

    • Obonye

      Member
      September 9, 2024 at 7:04 am

      I have created subform object in a secondary remote form. I have also created a primary form where I have buttons to select which subform to open in the secondary remote form. The $classname of the subform is assigned dynamically depending on the button clicked on the primary remote form. If I test the form for the first time, it runs okay and opens the subform. But fails a second test run. I therefore step through the code to catch where it is failing. The stack goes through the $event method of the button in the primary form, opens the secondary form but fails to step into the $construct of the secondary remote form. To assign the $classname property of the subform i run this code:<br clear=”none”>Do $cinst.$objs.SubFormHorzHeader.$classname.$assign(jsSFAddData)

      The “subformset_remove” is in the $destruct of the secondary form that contains the pagedpane.

  • Andreas Pfeiffer

    Administrator
    September 9, 2024 at 7:15 am

    So if I understand you right you are using a subform component to display different subforms there. And within that form you are using a subformset. But for some reason it does not run into the $destruct method of the subform?

    Please check if $multipleclasses of the subform field is set to kTrue. Make it kFalse and you should then then see the $desctruct of the subform to be executed when you assign a new $classname.

    If $multipleclasses is kTrue that would mean that you can maintain several instances at the very same time. So any instance that has been constructed will stay alive until you either close it manually or close the main form that contains the subform component. That means in return that when re-assigning a classname that has been used before will also not execute the $construct of that subform either.

    I figured it is easier in most cases to leave this property to kFalse.

    Best,

    Andreas

    • Obonye

      Member
      September 9, 2024 at 7:35 am

      $multipleclasses is kFalse

  • Andreas Pfeiffer

    Administrator
    September 9, 2024 at 7:37 am

    $multipleclasses is set to kFalse and the $destruct is not executed of the formerly used subform when you assign another $classname?

    • Obonye

      Member
      September 9, 2024 at 7:42 am

      Actually, $construct is not run a second time I open the secondary form from the primary form.

      • Obonye

        Member
        September 9, 2024 at 7:44 am

        Actually, $construct is not run a second time I open the secondary form from the primary form. This only happens IF I put “subformset_remove” in the $destruct. If I remove it, the $construct is hit as second time.

  • Andreas Pfeiffer

    Administrator
    September 9, 2024 at 7:43 am

    Do you open the same or another form?

    • Obonye

      Member
      September 9, 2024 at 7:45 am

      Sorry I was talking over you.

      Actually, $construct is not run a second time I open the secondary form from the primary form. This only happens IF I put “subformset_remove” in the $destruct. If I remove it, the $construct is hit as second time.

      Martin.

  • Andreas Pfeiffer

    Administrator
    September 9, 2024 at 7:48 am

    Martin,

    I think we are confusing ourselves right now. Let me point out. The subformset does not have to do anything with using a subform control.

    I am assuming that one of your subforms that you are using within the subform field is then itself using a subformset panel. Is this correct?

    Best,

    Andreas

    • Obonye

      Member
      September 9, 2024 at 7:51 am

      one of your subforms that you are using within the subform field is then itself using a subformset panel. Is this correct? Yes. This is my setup

  • Andreas Pfeiffer

    Administrator
    September 9, 2024 at 7:53 am

    and this one does not run into $destruct once you are assigning another form to the $classname of the subform field?

    • Obonye

      Member
      September 9, 2024 at 7:58 am

      No. It does not run into $construct of the same form I assigned to $classaname. Imagine a primary window with insert button opens a window with a back button. When I click the back button it will open the primary window. If I click on the insert button, it will assign the same $classname in the secondary window.

      • Obonye

        Member
        September 9, 2024 at 8:07 am

        Just to be clear. The problem is not with $destruct. The problem is with not running the $construct. But I noticed it happens if I insert “subformset_remove”, in the $destruct of the secondary form that contains the pagedpane that contains the subformpanelset.

      • Andreas Pfeiffer

        Administrator
        September 9, 2024 at 8:24 am

        Martin,

        You cannot assign the same form into $classname as before. It must be a different in order to change the form. Therefore it will not destruct and not construct.

        • Andreas Pfeiffer

          Administrator
          September 9, 2024 at 8:25 am

          However you could use a dummy form when the user clicks the back button.

          • Obonye

            Member
            September 9, 2024 at 8:31 am

            But why would this problem only happen when I insert “subformset_remove” in the $destruct of the secondary form? If I remove this command from $destruct, the problem goes away.

            • Andreas Pfeiffer

              Administrator
              September 9, 2024 at 8:32 am

              Sorry – without having more information it is quite impossible to say what you are trying to achieve. Could you upload a sample library for testing?

            • Obonye

              Member
              September 9, 2024 at 11:14 am

              I have used a copy of the sample library. See the attachment. Play around with the insert and back button to see the error I’m running into. The “subformset_remove” is in the $destruct.

            • Obonye

              Member
              September 9, 2024 at 11:17 am

              Run the main form, “jsSubFormSetPanelsMain”

            • Obonye

              Member
              September 9, 2024 at 11:21 am

              I have used a copy of the sample library. See the attachment. Play around with the insert and back button to see the error I’m running into. The “subformset_remove” is in the $destruct. Use the main form, “jsSubFormSetPanelsMain”, to test.

              • This reply was modified 11 months, 2 weeks ago by  Obonye Mato.
  • Andreas Pfeiffer

    Administrator
    September 9, 2024 at 12:04 pm

    Hi Martin,

    Thanks for providing the sample library.

    I changed a couple of things though:

    1. Added “Do inherited” in the $construct of jsSubformSetPanels to make sure that the $construct of the superclass is alway executed.
    2. I added a Dummy remote form “jsDummy” to allow to properly close the existing instance.
    3. I changed the code in $event of the back button in the superclass to use $cinst.$container:

    On evClick

    Do $cinst.$container().$objs.subformpanelsset.$classname.$assign(“jsDummy”)

    # this will close the existing instance because the main form would assign an empty form to the subform component. I would probably make a new method in the main form that does this for better encapsulation. So for example you could have a $goback method in your main form that assigns the dummy form and then simply call this from your back button like this:

    Do $cinst.$container().$goback()

    4. Finally I moved the code to remove the subformset to the back button in the concrete form jsSubformSetPanels because if you do this in the $destruct it is apparently too late. So I overrode the $event method if the back button of the concrete class like this:

    On evClick

    Do $cinst.$clientcommand(“subformset_remove”,row(‘SubformPanelsSet’))

    Do inherited

    Attached please find the corrected Omnis Studio 11.1 library.

    Best,

    Andreas

  • Andreas Pfeiffer

    Administrator
    September 10, 2024 at 12:09 pm

    Thank you Martin!

    Have a good day!

    Best,

    Andreas

    • Obonye

      Member
      October 2, 2024 at 7:23 am

      Hi, the subform panelsset has $cinst.$title to define the name of the panelsset. Is there a way to assign the background color of the panelsset title?

      • Andreas Pfeiffer

        Administrator
        October 8, 2024 at 9:57 am

        Hi Martin,

        I would think you would need to do this in a CSS class.

        Best,

        Andreas

        • Andreas Pfeiffer

          Administrator
          October 8, 2024 at 10:30 am

          For example: add the following to your user.css file:

          .omnis-wf-title-text {

          background-color:aliceblue !important;

          }

          • Obonye

            Member
            October 8, 2024 at 11:59 am

            The CSS has worked like a charm. Love it! My week-long wait has finally paid off.

            • Andreas Pfeiffer

              Administrator
              October 8, 2024 at 12:03 pm

              Awesome!

              Have a great day!

Log in to reply.