Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Set list grid height to content OR available space with scrollbars

    Small question about the "autoFit" feature for list grids:
    I want to set the height dynamically growing with the number of records but if the available vertical space is not sufficient do not expand further but start showing a scrollbar.
    I tried
    Code:
    setAutoFitData(Autofit.VERTICAL);
    setOverflow(Overflow.AUTO);
    setBodyOverflow(Overflow.AUTO);
    but without success. It should be simple but I'm missing something.
    Thanks!

    #2
    Use autoFitMaxRecords.

    Do not set overflow or bodyOverflow.

    Comment


      #3
      Well, I tried
      Code:
      autoFitMaxRecords()
      but it (in accordance to the docs) still grows the grid with the number of records no matter how much space is actually available.
      Again, what i want is: gridHeigth = min(height(all_records), available_height) and not a fixed max height.
      Am I correct that this behaviour is currently not possible?
      Thanks.

      Comment


        #4
        There's nothing "fixed" about autoFitMaxHeight, since you can provide it dynamically if you have some special concept of the "available height".

        Normally a grid would be placed into a VLayout or VStack to manage its height along with other components. In that case the Layout provides the grid with the available height based on the other components in it, and its parents (if any) - the Layout docs cover this. If there is some specific notion of "available height" that you can't see to get with (possibly nested) Layouts, we'd need to know specifics for what that is, and how you expect the other, surrounding components to behave.

        Comment


          #5
          This is no "special concept" of the available height cause it would be the behaviour that setOverflow(Overflow.AUTO) (or setBodyOverflow(Overflow.AUTO) in case of grids) would normally create for any other canvas widgets.

          And this has also nothing to do with any layouts or other surrounding widgets. Let's say there is only one list grid, nothing else to show, with setAutoFitData(Autofit.VERTICAL). It has 10 records and the overall size of the grid is set so that these 10 are shown. However, if the browser window is made too small, the grid height does not change (this is what i want) but the browser window starts showing a scrollbar.

          With setHeight100() the grid size adjusts to the available space and shows a scrollbar (inside the grid) if there is not enough space to show all records. I want this behaviour combined with setAutoFitData(). A third time: is this somehow possible?

          Comment


            #6
            If you wanted to do this without a Layout for some reason, in your scenario of just filling the browser window, you would provide the height of the browser window as the autoFitMaxHeight.

            Otherwise, within a Layout, you'd just set autoFitData:vertical with no maximums, set the Layout to overflow:auto, and the Layout will provide scrolling if there's not enough space to show all the records. It can also use other components to fill any extra available space when there are just a few records.

            You did ask for a scrollbar within the grid - we're not sure why that's important, or if it is, why you would refuse to use autoFitMaxRecords to achieve that, which it does. But if it's somehow critical for you, you could place the grid within a Canvas and set the autoFitMaxHeight to the height of the Canvas each time the Canvas was resized. It's not clear what the point of this would be - it would just achieve leaving blank space under the grid. Our technology is for functionally dense, enterprise apps and such apps don't leave blank space, so this is not a scenario we focus on. Still, it's easily achieved.

            Comment


              #7
              Originally posted by Isomorphic View Post
              you could place the grid within a Canvas and set the autoFitMaxHeight to the height of the Canvas each time the Canvas was resized
              This is was I was looking for. Thought it would be easier, but thanks anyway!

              Comment

              Working...
              X