Announcement

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

    ListGrid setGroupPadding is ignored if called after fetchData

    I don't know if I'm misunderstanding the doc (does fetchData() cause the widget to get created?) but I have noticed the behavior where calling setGroupPadding() after fetchData() on a isGroup=true ListGrid causes the setGroupPadding() to be ignored and the default value of 10 to be used instead.

    Click image for larger version

Name:	listgrid-grouped-fetchdatapadding_smartgwt-13.1d-20230603.jpg
Views:	59
Size:	36.2 KB
ID:	270283
    The SmartGWT version is 13.1d-20230603 but I've already observed this in a prior version 13.1d-20230522.

    Just dropping a note in case if this isn't an intended behavior.

    Code:
    import com.google.gwt.user.client.ui.RootPanel;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.Layout;
    
    public class SmartGridWoes extends Canvas {
        public SmartGridWoes() {
            this.setBackgroundColor("#e0ffe0");
            this.setHeight100();
            this.setWidth100();
    
            Layout main = new HLayout();
    
            main.setBackgroundColor("cyan");
            main.setPadding(10);
            main.setMembersMargin(10);
    
            ListGrid grid1 = new ListGrid();
            grid1.setWidth(300);
            grid1.setHeight(200);
            main.addMember(grid1);
    
            ListGrid groupedGrid1 = new ListGrid();
            groupedGrid1.setWidth(300);
            groupedGrid1.setHeight(200);
            groupedGrid1.setIsGroup(true);
            groupedGrid1.setGroupTitle("Grouped grid 1");
            // Remove the default padding of 10, but not the margin
            // between the title and the grid's header.
            groupedGrid1.setGroupPadding(0);
            // Now this removes the extra header space:
            groupedGrid1.setLeaveGroupLabelSpace(false);
            main.addMember(groupedGrid1);
    
            ListGrid groupedGridFetchDataAfterPadding = new ListGrid();
            groupedGridFetchDataAfterPadding.setWidth(300);
            groupedGridFetchDataAfterPadding.setHeight(200);
            groupedGridFetchDataAfterPadding.setIsGroup(true);
            groupedGridFetchDataAfterPadding.setGroupTitle("Fetch data after padding");
            // Sets the padding to 25 as intended.
            groupedGridFetchDataAfterPadding.setGroupPadding(25);
            groupedGridFetchDataAfterPadding.fetchData();
            main.addMember(groupedGridFetchDataAfterPadding);
    
            ListGrid groupedGridFetchDataBeforePadding = new ListGrid();
            groupedGridFetchDataBeforePadding.setWidth(300);
            groupedGridFetchDataBeforePadding.setHeight(200);
            groupedGridFetchDataBeforePadding.setIsGroup(true);
            groupedGridFetchDataBeforePadding.setGroupTitle("Fetch data before padding");
            // Calling fetchData() before setGroupPadding() will cause
            // the set padding to be ignored.
            groupedGridFetchDataBeforePadding.fetchData();
            // refreshData() -- same thing
            //groupedGridFetchDataBeforePadding.refreshData();
            groupedGridFetchDataBeforePadding.setGroupPadding(25);
            main.addMember(groupedGridFetchDataBeforePadding);
    
            addChild(main);
            RootPanel.get().add(this);
        }
    }

    #2
    Fetching data will draw() the grid and, right now, Canvas.setGroupPadding() is not supported after draw.

    We may look at making it available after draw() but, in the meantime, just call it during initial setup - or if you always want this behavior, apply your settings globally to all widgets with Canvas.setDefaultProperties(), or create a subclass of ListGrid with your settings applied and use that grid-type pervasively.
    Last edited by Isomorphic; 7 Jun 2023, 21:56.

    Comment

    Working...
    X