Announcement

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

    grid's summaryRow fetched every time paging occurs

    Hi,
    This is modified showcase sample https://www.smartclient.com/smartcli...OperatorFilter
    Click image for larger version

Name:	summaryRow2.png
Views:	118
Size:	30.1 KB
ID:	253880
    Code:
    isc.ListGrid.create({
        ID: "countryList",
        width:550, height:300, alternateRecordStyles:true,
        dataSource: worldDS,
    showGridSummary: true,
    summaryRowDataSource: worldDS,
    summaryRowCriteria: {pk:1},
    
        fields:[
            {name:"countryCode", width:60},
            {name:"countryName"},
            {name:"capital"},
            {name:"continent"},
            {name:"area"},
            {name:"population"}
        ],
        autoFetchData: true,
        showFilterEditor: true,
        allowFilterOperators: true,
        initialCriteria: { _constructor: "AdvancedCriteria", operator: "and",
            criteria: [
                { fieldName: "countryName", operator: "iNotContains", value: "i" },
                { fieldName: "capital", operator: "iNotStartsWith", value: "p" }
            ]
        }
    });
    Modification:
    Code:
    showGridSummary: true,
    summaryRowDataSource: worldDS,
    summaryRowCriteria: {pk:1},
    imitate server side summary which is issued during filter operation. Below is developer console view with two fetches: one filling first page of the grid and second getting summary record. This is fine.
    Click image for larger version

Name:	summaryRow0.png
Views:	133
Size:	11.5 KB
ID:	253878
    Now, scroll to the bottom of the grid and inspect console again.
    Click image for larger version

Name:	summaryRow1.png
Views:	105
Size:	18.6 KB
ID:	253879
    There is a new portion of records fetched due to page scroll. But summary fetch is issued again which should not occur to me.
    In our application summary rows from server are widely used and (not surprising) are server resources hungry and time consuming, so repeated every set of records stress the server needlessly.
    Thanks,
    MichalG
    ps tested in showcase version v12.0p_2018-06-28/AllModules Development Only (built 2018-06-28)

    #2
    We're looking into this presently.

    Comment


      #3
      This should be fixed back to SC 11.1p in todays builds, dated 2018-07-06.

      Comment


        #4
        Not quite.
        Although it is indeed fixed when tested in above modified showcase example (no summary row data fetch during paging), there is a bad side effect when latest smartgwt.jar is used in our application. This side effect can be traced using the following test case:
        Code:
        import com.google.gwt.core.client.EntryPoint;
        import com.smartgwt.client.data.DSRequest;
        import com.smartgwt.client.data.DSResponse;
        import com.smartgwt.client.data.DataSourceField;
        import com.smartgwt.client.data.Record;
        import com.smartgwt.client.data.RestDataSource;
        import com.smartgwt.client.data.fields.DataSourceFloatField;
        import com.smartgwt.client.data.fields.DataSourceTextField;
        import com.smartgwt.client.widgets.grid.ListGrid;
        
        public class MainEntryPoint implements EntryPoint {
        
            public void onModuleLoad() {
        
                layout();
            }
        
            private void layout() {
                final RestDataSource ds = new RestDataSource() {
                    @Override
                    protected void transformResponse(DSResponse dsResponse, DSRequest dsRequest, Object data) {
                        if (dsRequest.getOperationId() != null && dsRequest.getOperationId().startsWith("SUM")) {
                            float sum = 0;
                            for (Record record : dsResponse.getData()) {
                                sum = sum + record.getAttributeAsFloat("quantity");
                            }
                            Record record = new Record();
                            record.setAttribute("quantity", sum);
                            dsResponse.setData(record);
                            dsResponse.setStartRow(0);
                            dsResponse.setEndRow(1);
                            dsResponse.setTotalRows(1);
                        }
                    }
                };
                ds.setDataURL("UnitDir.xml");
                DataSourceField fieldId = new DataSourceField();
                fieldId.setName("id");
                fieldId.setPrimaryKey(true);
                fieldId.setHidden(true);
                DataSourceTextField fieldCode = new DataSourceTextField();
                fieldCode.setName("code");
                DataSourceFloatField fieldQuantity = new DataSourceFloatField();
                fieldQuantity.setName("quantity");
                ds.setFields(fieldId, fieldCode, fieldQuantity);
        
                ListGrid lg = new ListGrid();
                lg.setHeight(200);
                lg.setDataSource(ds);
                lg.setAutoFetchData(true);
                lg.setShowFilterEditor(true);
                lg.setShowGridSummary(true);
                lg.setSummaryRowDataSource(ds);
                DSRequest summaryRowFetchRequestProperties = new DSRequest();
                summaryRowFetchRequestProperties.setOperationId("SUM(quantity)");
                lg.setSummaryRowFetchRequestProperties(summaryRowFetchRequestProperties);
        
                lg.draw();
            }
        }
        Data file used by example code UnitDir.xml
        Code:
        <response>
            <requestId>UnitDir_request5</requestId>
            <startRow>0</startRow>
            <endRow>76</endRow>
            <totalRows>77</totalRows>
            <data>
                <UnitDir>
                    <id>341</id>
                    <code>kg</code>
                    <description>kilogram</description>
                    <validFrom>2015-05-26</validFrom>
                    <validTo>2015-05-28</validTo>
                    <quantity>10.5</quantity>
                </UnitDir>
                <UnitDir>
                    <id>342</id>
                    <code>szt</code>
                    <description>sztuki</description>
                    <validFrom>2015-05-26</validFrom>
                    <quantity>11.75</quantity>
                </UnitDir>
                <UnitDir>
                    <id>343</id>
                    <code>sztuki</code>
                    <description>sztuki</description>
                    <validFrom>2015-05-26</validFrom>
                    <quantity>10000</quantity>
                </UnitDir>
            </data>
            <requestedDataSource>UnitDir</requestedDataSource>
            <status>STATUS_SUCCESS</status>
        </response>
        Run test example
        Click image for larger version  Name:	summaryCriteria0.png Views:	1 Size:	5.8 KB ID:	253985
        and enter criteria for "Code" field for example "kg" then hit enter or filter grid.
        Click image for larger version  Name:	summaryCriteria1.png Views:	1 Size:	4.3 KB ID:	253986
        You can see that grid's summary row stays white - not filled. Clear criteria and filter again - summary row is displayed correctly.
        Looks like summary row filling logic is not triggered when criteria are set or changed.
        Thanks,
        MichalG
        ps
        SmartClient Version: v12.0p_2018-07-07/LGPL Development Only (built 2018-07-07)
        Last edited by michalg; 9 Jul 2018, 06:57. Reason: add SGWT version

        Comment


          #5
          We see the issue, but you know that even if a refetch does occur, your sample code calculates the summary of all the rows in the fixed response and reports that, even with the filter set to show just "kg", right?

          Comment


            #6
            Right.
            Thanks,
            MichalG

            Comment


              #7
              We've improved the earlier fix applied to SC 11.1p and newer branches so that it should trigger a new fetch in those cases where it may be required - but not during scrolling. This will be in the ngihtly builds dated 2018-07-12 and beyond.

              Comment


                #8
                Verified as fixed in build 12.0p 2018-07-13.
                Thank you very much.
                MichalG

                Comment

                Working...
                X