Home › Forum › Omnis General Forum › Subform Set Panel
-
Subform Set Panel
Posted by Obonye on September 6, 2024 at 1:27 pmHi $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
-
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
-
This reply was modified 11 months, 2 weeks ago by
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
-
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
-
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.
-
Martin,
This is because closing the form does not close the subformset. You also would need to close the subformset.
Best,
Andreas
-
subformset_remove
This is documented here: https://www.omnis.net/developers/resources/onlinedocs/WebDev/02jsremoteforms.html#subform-sets-1
Best,
Andreas
-
The documentation reference has really helped. The command below has closed the subformset:
Do $cinst.$clientcommand(“subformset_remove”,row(‘SubformPanelsSet’))
Thank you.
-
Awesome! This is great!
Have a nice evening then.
Best,
Andreas
-
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.
-
-
-
-
This reply was modified 11 months, 2 weeks ago by
-
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
-
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.
-
-
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
-
This reply was modified 11 months, 2 weeks ago by
Andreas Pfeiffer.
-
This reply was modified 11 months, 2 weeks ago by
-
$multipleclasses is set to kFalse and the $destruct is not executed of the formerly used subform when you assign another $classname?
-
Actually, $construct is not run a second time I open the secondary form from the primary form.
-
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.
-
-
-
-
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.
-
-
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
-
This reply was modified 11 months, 2 weeks ago by
Andreas Pfeiffer.
-
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
-
This reply was modified 11 months, 2 weeks ago by
-
and this one does not run into $destruct once you are assigning another form to the $classname of the subform field?
-
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.
-
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.
-
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.
-
However you could use a dummy form when the user clicks the back button.
-
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.
-
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?
-
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.
-
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.
-
This reply was modified 11 months, 2 weeks ago by
-
-
-
-
-
-
Hi Martin,
Thanks for providing the sample library.
I changed a couple of things though:
- Added “Do inherited” in the $construct of jsSubformSetPanels to make sure that the $construct of the superclass is alway executed.
- I added a Dummy remote form “jsDummy” to allow to properly close the existing instance.
- 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
-
Thank you for prompt response. I’m using v10.22 not v11.1. Can I be helped? I’ll upgrade later on.
-
Martin,
Ok – I made the changes in the 10.22 for you. Please see attached.
Best,
Andreas
-
Hi @andreas-pfeiffer , this solution worked perfectly for me. I appreciate your help very much. You make Omnis such a wonderful product, and easy to use over time. 🙂
-
-
-
Thank you Martin!
Have a good day!
Best,
Andreas
-
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?
-
Hi Martin,
I would think you would need to do this in a CSS class.
Best,
Andreas
-
For example: add the following to your user.css file:
.omnis-wf-title-text {
background-color:aliceblue !important;
}
-
The CSS has worked like a charm. Love it! My week-long wait has finally paid off.
-
-
-
-
Log in to reply.