Announcement

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

    12.1p Problem with ListGrid grouping and setSummaryRowDataSource()

    Hi Isomorphic,

    using v12.1p_2022-08-10 and retesting it with v12.1p_2023-06-27 I noticed some problems in my application with ListGrid grouping and setSummaryRowDataSource().

    #1: Check "Aggregate?": The summaryRow is displayed all over and no data is displayed (see screenshot).
    #2: Check "Aggregate?" and "Group at start?": Same, plus the aggregation request is sent twice (so four in total: Normal 0-1000 (OK), Normal 0-75 (OK), 2x Agg (1x expected)

    All the other options are there to test more special cases, as I thought it also related to aggregation-request timing.

    Please see the attached testcase.

    Best regards
    Blama


    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.AdvancedCriteria;
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.types.GroupStartOpen;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.types.SummaryFunctionType;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.ButtonItem;
    import com.smartgwt.client.widgets.form.fields.CheckboxItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            VLayout mainLayout = new VLayout(20) {
                {
                    setWidth100();
                    setHeight100();
                    DynamicForm confDF = new DynamicForm();
                    confDF.setNumCols(1);
                    confDF.setWidth(250);
                    CheckboxItem groupAtStart = new CheckboxItem("groupAtStart", "Group at start?");
                    groupAtStart.setDefaultValue(false);
                    CheckboxItem lessThan1000 = new CheckboxItem("lessThan1000", "Less than 1000 records?");
                    lessThan1000.setDefaultValue(false);
                    CheckboxItem showGridAgg = new CheckboxItem("showGridAgg", "Aggregate?");
                    showGridAgg.setDefaultValue(false);
                    CheckboxItem aggSlowCBI = new CheckboxItem("aggSlow", "Aggregation slow?");
                    aggSlowCBI.setDefaultValue(false);
                    CheckboxItem fetchSlowCBI = new CheckboxItem("fetchSlow", "Normal fetch slow?");
                    fetchSlowCBI.setDefaultValue(false);
    
                    ButtonItem start = new ButtonItem("btn", "Open Window");
                    start.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
                        @Override
                        public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
                            recreate((Boolean) confDF.getValue("aggSlow"), (Boolean) confDF.getValue("fetchSlow"), (Boolean) confDF.getValue("showGridAgg"),
                                    (Boolean) confDF.getValue("groupAtStart"), (Boolean) confDF.getValue("lessThan1000"));
                        }
                    });
                    confDF.setFields(groupAtStart, lessThan1000, showGridAgg, aggSlowCBI, fetchSlowCBI, start);
    
                    addMembers(confDF);
                }
            };
            mainLayout.draw();
        }
    
        private void recreate(boolean aggSlow, boolean fetchSlow, boolean showGridAgg, boolean groupAtStart, boolean lessThan1000) {
            Window w = new Window();
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("12.1p Problem with ListGrid grouping and setSummaryRowDataSource()" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final ListGrid listGrid = new ListGrid(DataSource.get("supplyItem")) {
                {
                    setHeight100();
                    setAutoFetchData(true);
                    if (groupAtStart) {
                        setGroupByField("category");
                    }
                    if (lessThan1000) {
                        setInitialCriteria(new AdvancedCriteria("itemName", OperatorId.LESS_OR_EQUAL, "D"));
                    }
                    setSortByGroupFirst(true);
                    setShowGroupSummary(true);
                    setGroupStartOpen(GroupStartOpen.ALL);
                    setSortField("itemName");
                    setShowFilterEditor(true);
                    if (showGridAgg) {
                        setShowGridSummary(true);
                    }
    
                    setSummaryRowDataSource(DataSource.get("supplyItem"));
    
                    if (fetchSlow) {
                        setFetchOperation("fetchSlow");
                    }
    
                    setSummaryRowFetchRequestProperties(new DSRequest() {
                        {
                            if (aggSlow)
                                setOperationId("fetchAggSlow");
                            else
                                setOperationId("fetchAgg");
                        }
                    });
    
                    ListGridField itemID = new ListGridField("itemID");
                    itemID.setSummaryFunction(SummaryFunctionType.SUM);
                    ListGridField itemName = new ListGridField("itemName");
                    ListGridField SKU = new ListGridField("SKU");
                    ListGridField category = new ListGridField("category");
                    ListGridField units = new ListGridField("units");
                    ListGridField unitCost = new ListGridField("unitCost");
                    unitCost.setSummaryFunction(SummaryFunctionType.AVG);
    
                    ListGridField inStock = new ListGridField("inStock");
    
                    setFields(itemID, itemName, SKU, category, units, unitCost, inStock);
                }
            };
    
            HLayout btnLayout = new HLayout(10);
            btnLayout.setPadding(5);
            btnLayout.addMembers(new IButton("No filter", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    listGrid.fetchData();
                }
            }), new IButton("<1000 entries", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    listGrid.fetchData(new AdvancedCriteria("itemName", OperatorId.LESS_OR_EQUAL, "D"));
                }
            }), new IButton("Group ListGrid", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    listGrid.groupBy("category");
                }
            }));
    
            VLayout vLayout = new VLayout(10) {
                {
                    addMembers(btnLayout, listGrid);
                }
            };
            w.addItem(vLayout);
            w.show();
        }
    }
    SupplyItem.java:
    Code:
    package com.smartgwt.sample.server.listener;
    
    import javax.servlet.http.HttpServletRequest;
    
    import com.isomorphic.datasource.DSRequest;
    import com.isomorphic.datasource.DSResponse;
    
    public class SupplyItem {
        public DSResponse fetchSlow(DSRequest request, HttpServletRequest servletRequest) throws Exception {
            Thread.sleep(500);
            return request.execute();
        }
    };
    supplyItem.ds.xml addition:
    Code:
    <serverObject lookupStyle="new" className="com.smartgwt.sample.server.listener.SupplyItem" />
        <operationBindings>
            <operationBinding operationType="fetch" operationId="fetchSlow" serverMethod="fetchSlow" />
            <operationBinding operationType="fetch" operationId="fetchAgg">
                <selectClause>SUM(itemID) as itemID, AVG(unitCost) AS unitCost</selectClause>
            </operationBinding>
            <operationBinding operationType="fetch" operationId="fetchAggSlow" serverMethod="fetchSlow">
                <selectClause>SUM(itemID) as itemID, AVG(unitCost) AS unitCost</selectClause>
            </operationBinding>
        </operationBindings>
    Click image for larger version

Name:	ListGridSummaryRow.PNG
Views:	99
Size:	10.7 KB
ID:	270479

    #2
    Hi Isomorphic,

    the double fetch from issue 2 is more easily recreated using this modified sample (v12.1p_2023-06-27):
    Code:
    isc.ListGrid.create({
        ID:"dsListGrid",
        width: "100%",
        height: "100%",
        autoFetchData: true,
        dataSource: "supplyItem",
        groupByField:"category",
        showGridSummary: true,
        summaryRowDataSource: "supplyItem",
        summaryRowCriteria: {"SKU": 45300},
        sortField:"itemName",
        sortByGroupFirst: true // Triggers the 2nd (row 0-75) fetch (OK, because of changed sorting) and I think somehow also the 2nd aggregation-fetch (unexpected).
    });
    For the "all screen summaryRow issue" you still need the SmartGWT sample.

    Best regards
    Blama

    Comment


      #3
      Your issue #1 should be fixed by the changes we made for your other thread.

      For #2, what you're seeing is actually expected behavior. That's because when the second fetch is made by the main grid, we ultimately call dataChanged(), which refreshes all the grid summaries. When the summary row is refreshed, it simply refetches the summary row data with the existing criteria.

      You're welcome to propose a Feature Sponsorship if you'd like us to make specific optimizations in this area.

      Comment


        #4
        Hi Isomorphic,

        thanks, I can see the issue from #1 is closed using v12.1p_2023-07-13. Regarding the double fetch it's fine for me if it is working as designed.
        I found a different issue with the same test code thoug. I will start a new thread for it.

        One other thing here, though. The sample starts in Enterprise skin. What is the quickest way to change it to Tahoe?

        Best regards
        Blama

        Comment


          #5
          This is the issue mentioned in #4.

          Comment

          Working...
          X