Announcement

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

    visual quirk with ListGrid.setAutoFitData(Autofit.VERTICAL)

    SmartClient Version: v12.0p_2019-05-14/LGPL Development Only (built 2019-05-14)
    Chrome Version 74.0.3729.157 (Official Build) (64-bit)

    When a ListGrid has setAutoFitData(Autofit.VERTICAL), and there is only 1 record, it renders oddly with the outer border extending beyond the grid body:

    Click image for larger version  Name:	quirk.png Views:	1 Size:	6.9 KB ID:	257880

    I tracked this down to _getDefaultMinHeight in ISC_Grids.js on line 21112:

    Code:
        _getDefaultMinHeight : function () {
            var minHeight = this.cellHeight + this.getVMarginBorderPad();
    
            if (this.showHeader)       minHeight += this.headerHeight;
            if (this.showFilterEditor) minHeight += this.filterEditorHeight;
            if (this.showEmptyMessage) minHeight += this._getEmptyMessageStyleVPad();
            if (this.showGridSummary)  minHeight += this.summaryRowHeight;
            return minHeight;
        },
    Specifically, _getEmptyMessageStyleVPad adds 22 pixels (for Enterprise skin) of height even when cellHeight would be sufficient to contain the empty message.

    Fortunately, there's an easy work-around: setShowEmptyMessage(false):
    Click image for larger version  Name:	with_fix.png Views:	1 Size:	6.7 KB ID:	257881

    FWIW, the previous version of smartgwt we were using, 5.0p from 2015-01-14, did not have this glitch.

    Maybe this could be fixed by using the greater of (_getEmptyMessageStyleVPad()+space for the text) or cellHeight instead of the sum?

    Anyway, not a big deal since there's an easy work-around, but I figured I'd report it.

    Example code:
    Code:
    public class AutoFitDataTestWindow extends Window
    {
        AutoFitDataTestWindow()
        {
            setAutoSize(true);
            final VLayout layout = new VLayout()
            {{
                setWidth(500);
                setHeight(500);
                setMargin(30);
                setBackgroundColor("#99CCFF");
    
                final ListGrid testGrid = new ListGrid()
                {{
                    setWidth(300);
                    setHeight(69);
                    // setShowEmptyMessage(false); uncomment to fix display
    
                    setAutoFitData(Autofit.VERTICAL);
    
                    final ListGridField inspectionPoint = new ListGridField("inspectionPoint", "Inspection Point");
                    final ListGridField defects = new ListGridField("defects", "Defects");
                    setFields(inspectionPoint, defects);
    
                    setData(createTestData(1));
    
                    addDrawHandler(drawEvent -> setAutoHeight());
                }};
    
                setMembers(testGrid);
            }};
    
            addItem(layout);
        }
    
        private static ListGridRecord[] createTestData(int n)
        {
            final Supplier<ListGridRecord> s = () -> new ListGridRecord()
            {{
                setAttribute("inspectionPoint", "test inspectionPoint");
                setAttribute("defects", "test defects");
            }};
    
            return Stream.generate(s).limit(n).toArray(ListGridRecord[]::new);
        }
    }

    #2
    Originally posted by jaysmith2020 View Post

    Specifically, _getEmptyMessageStyleVPad adds 22 pixels (for Enterprise skin) of height even when cellHeight would be sufficient to contain the empty message.
    Actually, no the cellHeight isn't sufficient, as there is vertical padding above and below the empty message text, represented by that vpad property.

    Originally posted by jaysmith2020 View Post
    Maybe this could be fixed by using the greater of (_getEmptyMessageStyleVPad()+space for the text) or cellHeight instead of the sum?
    That wouldn't make sense as that vpad quantity is required in addition to the cellHeight.

    Comment


      #3
      Ok, yes, in an uncustomized skin where there 22 px of padding and the default cellHeight is 22, then that is true. But add setCellHeight(200), and it still looks like this:

      Click image for larger version

Name:	tall_example.png
Views:	67
Size:	7.4 KB
ID:	257884

      Comment


        #4
        The empty message always occupies a full cellHeight, plus its top and bottom padding, regardless of the cellHeight value, so that calculation is still correct. It seems like the problem is the styling that you're applying that shows the ListGrid background beyond the ListGridBody as a different color. While we have skins that do that, our default and most popular skins don't.

        Comment


          #5
          Note further that the function you mention above is only used to default the value of ListGrid.minHeight if it's not been set. You are free to set a minHeight as you please which should prevent that function from ever being called.

          Comment


            #6
            Thanks for the feedback. FWIW, my screen shot project is using <inherits name="com.smartclient.theme.enterprise.EnterpriseResources" /> provided by smartgwt.jar (v12.0p_2019-05-14/LGPL).

            Comment

            Working...
            X