Announcement

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

    Disabling autofit and keeping the same list grid height?

    Hello, I have a list grid which has autoFitData set to vertical and AutoFitMaxHeight set to 400. After the grid is drawn, I'd like to disable the autofit so that the user can vertically resize the VLayout which contains the grid, because it seems that the grid autofit is preventing the resize behavior of the parent VLayout via drag and drop. However, if I disable the grid's autofit after it is drawn, the grid goes back to the default height of 100. Is it possible to disable autofit and keep the grid height the same? If not, is there any way to maintain the autofit and allow the parent VLayout to be resized with drag & drop? Thank you.

    #2
    Normally you would just setHeight() to the grid's current height before disabling autofit - did you already try that and have trouble with it?

    Comment


      #3
      Originally posted by Isomorphic View Post
      Normally you would just setHeight() to the grid's current height before disabling autofit - did you already try that and have trouble with it?
      Yes, I had tried this, but it did not work. Just tried again to verify. When I get the grid's current height, it incorrectly tells me the height is 100, instead of the autofitted height which is 400 based on the max autofit size (but this could be less if I had less records in the grid).

      This is my code:

      Code:
              columnsGrid.addDrawHandler(new DrawHandler() {
      
                  @Override
                  public void onDraw(DrawEvent event) {
                      int height = columnsGrid.getHeight();
                      int width = columnsGrid.getWidth();
                      BCUtils.logToSC("width is: " +  width + " height : " + height);  //This prints out the height as 100, even though it's actually around 400 due to the grid being autofitted to the max autofit height
      //                columnsGrid.setAutoFitData(null);
      //                columnsGrid.resizeTo(width, height);
                  }});
      
              columnsGrid.setAutoFitData(Autofit.VERTICAL);
              columnsGrid.setAutoFitMaxHeight(400);

      Comment


        #4
        See docs- getHeight is the configured height, so the value of 100 is correct. Use getVisibleHeight() to get the current visible height.

        Comment


          #5
          Thank you, that helped me quite a lot. Also the resize behavior was not prevented by the grid's autofit - it was actually because I had my layout containing the grid set to Overflow.VISIBLE. So getting the layout's visible height (after everything is resized due to the grid's autofit) and then changing it to hidden overflow and setting the height to the previous resized height makes it work correctly.

          Comment

          Working...
          X