Home › Forum › Omnis General Forum › $currentlayoutbreakpoint in a jsForm
-
$currentlayoutbreakpoint in a jsForm
Posted by Obonye on December 11, 2023 at 10:32 amHow do I get the current layout breakpoint in a jsForm at runtime?
I have tried $subinst.$currentlayoutbreakpoint and $event evLayoutChanged then calculate lBreakpoint as pBreakpoint. Note that the layout is in a subform $layouttyperesponsive.
Andreas Pfeiffer replied 7 months, 1 week ago 2 Members · 21 Replies -
21 Replies
-
Hi Martin,
override the $event method of the subform like this:
On evLayoutChanged
Calculate iLayout as pBreakpoint ## iLayout is an integer instance variable.
Then you could add a method to the subform that returns that value:
$getLayout
Quit Method iLayout
So if you want to know in which layout the subform is from your main form you can then send a message to the subform like this:
Do $cinst.$objs.mySubformField.$subinst().$getLayout() Returns lSubformLayout
However I wonder why the main form supposed to bother in which layout breakpoint the subform is. Shouldn’t it organise by itself?
I hope this helps.
Best,
Andreas
-
The main form should not know the subform layout. So I do not see the need to send the iLayout to the main form as you have explained. The problem is I get a #null value when I trap the pBreakpoint in $event On evLayoutChanged in the subform.
-
This reply was modified 7 months, 1 week ago by
Obonye Mato.
-
that is weird. Which build do you use?
Best,
Andreas
-
-
That should be fine. Though why not using Omnis Studio 11?
-
Shouldn’t I learn all the features of 10.22 well then progress to a later version?
-
ha -ha. Why is that? Omnis Studio 11 has a lot of bugfixes and new features.
-
-
Btw. In Omnis Studio 11 you could just delete all layout breakpoints but one. Then either set the right and bottom edge float to the grid or – if you have only the grid in the subform making the edge float kEFPosnClient. Then the grid will be relative to the size of the subform control in the outer form.
-
-
-
-
Do you put the breakpoint after the evLayoutChanged?
-
yes, like this,
On evLayoutChanged
Calculate lBreakpoint as pBreakpoint
Switch pBreakpoint
Case 320
Do $cinst.$objs.DataGrid.$::columnwidths.$assign(‘250,50’)
Do $cinst.$objs.DataGrid.$width.$assign(‘300’)
-
-
This reply was modified 7 months, 1 week ago by
-
I would like to recommend for the first test using an instance variable and show it in an entry field in that subform to proof what layout breakpoint you are in.
On the other hand why do you assign column widths and the width of the component at all?
You can set $columnwidthsarepercentage=kTrue and then make sure each column has the right percentage width. The width property of the control should then automatically be controlled by the layout breakpoint the form is in. So no need to assign it at all.
-
That’s a great idea that will solve the layout issue. But how do I assign the column % in decimals eg 300/350*100=85.71 as column width? The $columnwidths property seems to accept integer values only.
-
If you set $columnwidthsarepersentage=ktrue you would only give a percentage value for each column. For example 10 means 10% of the entire width.
-
Your solution is great @andreas-pfeiffer . The column width issue is now sorted. This forum is super-lovely.
-
Martin,
I am glad it works for you. Thanks for the feedback.
Have a good day 🙂
Andreas
-
There is still a small issue. In my datagrid, I have 2 columns: name, and isselect. isselect column is a boolean. It remains the same width irrespective of the window layout. Therefore $columnwidtharepercentage should be kfalse. I have created an entry field in the subform with a dataname iBreakpoint. I have calculated iBreakpoint as pBreakpoint. If I test the form, the value is 0.
-
Hi Martin,
Not sure what you mean. The $columnwidtharepercentage is global for the grid. So if you set it it will certainly affect all of the columns.
I made a litte (Omnis Studio 11) sample library that shows how that works. Please see attached.
Best regards,
Andreas
-
A boolean column in a datagrid has a fixed width and there is no need to adjust it’s width by a percentage.
-
Hi Martin,
I have added an enhancement request to limit the width of a column when $columnwidthsarepercentage is set to kTrue.
Best regards,
Andreas
-
-
-
-
-
Log in to reply.