Forums

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

Home Forum Omnis General Forum $currentlayoutbreakpoint in a jsForm

  • $currentlayoutbreakpoint in a jsForm

    Posted by Obonye on December 11, 2023 at 10:32 am

    How 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
  • Andreas Pfeiffer

    Administrator
    December 11, 2023 at 10:38 am

    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

  • Obonye

    Member
    December 11, 2023 at 10:45 am

    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.
    • Andreas Pfeiffer

      Administrator
      December 11, 2023 at 10:52 am

      that is weird. Which build do you use?

      Best,

      Andreas

      • Obonye

        Member
        December 11, 2023 at 11:07 am

        $OS 10.22 build 31896

        • Andreas Pfeiffer

          Administrator
          December 11, 2023 at 11:27 am

          That should be fine. Though why not using Omnis Studio 11?

          • Obonye

            Member
            December 11, 2023 at 11:38 am

            Shouldn’t I learn all the features of 10.22 well then progress to a later version?

            • Andreas Pfeiffer

              Administrator
              December 11, 2023 at 12:10 pm

              ha -ha. Why is that? Omnis Studio 11 has a lot of bugfixes and new features.

          • Andreas Pfeiffer

            Administrator
            December 11, 2023 at 1:24 pm

            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.

    • Andreas Pfeiffer

      Administrator
      December 11, 2023 at 10:53 am

      Do you put the breakpoint after the evLayoutChanged?

      • Obonye

        Member
        December 11, 2023 at 11:06 am

        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’)

  • Andreas Pfeiffer

    Administrator
    December 11, 2023 at 11:20 am

    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.

    • Obonye

      Member
      December 11, 2023 at 11:36 am

      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.

      • Andreas Pfeiffer

        Administrator
        December 11, 2023 at 12:12 pm

        If you set $columnwidthsarepersentage=ktrue you would only give a percentage value for each column. For example 10 means 10% of the entire width.

        • Obonye

          Member
          December 11, 2023 at 1:07 pm

          Your solution is great @andreas-pfeiffer . The column width issue is now sorted. This forum is super-lovely.

          • Andreas Pfeiffer

            Administrator
            December 11, 2023 at 1:09 pm

            Martin,

            I am glad it works for you. Thanks for the feedback.

            Have a good day 🙂

            Andreas

            • Obonye

              Member
              December 11, 2023 at 3:38 pm

              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.

            • Andreas Pfeiffer

              Administrator
              December 11, 2023 at 3:51 pm

              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

            • Obonye

              Member
              December 11, 2023 at 3:59 pm

              Which version of Omnis is this library?

            • Andreas Pfeiffer

              Administrator
              December 11, 2023 at 4:00 pm

              The latest.

              Best,

              Andreas

            • Obonye

              Member
              December 11, 2023 at 4:08 pm

              A boolean column in a datagrid has a fixed width and there is no need to adjust it’s width by a percentage.

            • Andreas Pfeiffer

              Administrator
              December 12, 2023 at 8:33 am

              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.