Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

4.0 ListGrid getSummaryValue returns 0 when null is expected

$
0
0
Version: 4.0p-20130827 LGPL
Browser: Firefox 22.0, Linux

The 4.0 ListGrid returns 0 for null summary values. 3.0 returned null.
I would expect the function to either return null or the invalidSummaryValue marker.

Based off of the ListGrid.js file inside the smartgwt.jar debug folder, the ListGrid.getSummaryValue(records, field) function returns 0 for any "falsy" value returned from the summary function.

An excerpt from the ListGrid.js file, lines 24307-24316, comments removed:
Code:

            if (currentFunction != null) {
                var r = isc.SimpleType.applySummaryFunction(includedRecords, field, currentFunction, this);
                if (!r) r = 0;
                results[i] = r;
            }

The 3.0 ListGrid.js file simply assigns results[i] from isc.SimpleType.applySummaryFunction.

Simple test case:
Code:

public class SandboxEntry implements EntryPoint
{
        public SandboxEntry()
        {
        }

        @Override
        public void onModuleLoad()
        {
                ListGrid grid = new ListGrid();
                ListGridField testField = new ListGridField();
                testField.setName("testField");
                testField.setSummaryFunction(new SummaryFunction() {

                        @Override
                        public Object getSummaryValue(Record[] records, ListGridField field)
                        {
                                return null;
                        }
                });
                grid.setFields(testField);
                Record[] sampleData = new Record[1];
                sampleData[0]= new Record();
                sampleData[0].setAttribute("testField", "Some data");
                grid.setData(sampleData);
                grid.setShowGridSummary(true);
                grid.draw();
        }
}

I use several custom summary functions (distinct value, weighted average, etc), and use the null value to flag when I am unable to calculate a summary for the rows provided. I can change this to return " ", but I'd prefer to have the old behavior back. Thanks!

Viewing all articles
Browse latest Browse all 4756

Trending Articles