Announcement

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

    getGroupSummary usage

    Hello,

    I'm trying to configure a ListGridField to show 3 summary rows in the grid summary but only 1 in the group summary. Can you show me what I am doing wrong in the sample code below? With this configuration, I am getting an error that "object is not a function" from getGroupSummary. I've tried a few different ideas and can't get it to work properly so hoping you can help me figure it out.


    Code:
    field.summaryFunction=getFundAssetSumSummaryFunctions(true);
    field.getGroupSummary = getFundAssetSumSummaryFunctions();
    Code:
    function getFundAssetSumSummaryFunctions(returnAll){
    	
    	var summaryFunctions=[];
    
    
    
    	if(returnAll)
    		summaryFunctions.push(getLongSumSummaryFunction());
    		summaryFunctions.push(getShortSumSummaryFunction());
    	}
    		
    	summaryFunctions.push(getTotalSumSummaryFunction());
    	
    	return summaryFunctions;
    }

    #2
    Unlike listGridField.summaryFunction, 'getGridSummary' / 'getGroupSummary' is not set to an array of functions to executed, instead, it should be set up as a function which will return an array of results which will be shown (one per line)

    Regards
    Isomorphic Software

    Comment


      #3
      Ok, so I'm not clear how I can re-use my existing summary functions then. How can I configure this field to display 1 row for the group summary and 3 rows for the grid summary? Or, do I need to re-factor this extensively and duplicate code to achieve this?

      Comment


        #4
        You do have to refactor to achieve this - we use summaryFunction for both grid and group summaries by default but if you want different behavior in the two places you need to use the getGridSummary or getGroupSummary to override behavior for the specific summary, and, as noted the implementation is slightly different (function returning an array of results rather than an array of functions).

        However this can be a relatively simple refactor - for example, if you make your custom summary functions available somewhere - say on the field object, via:
        Code:
        field.getLongSumSummary = getLongSumSummaryFunction();
        field.getShortSumSummary = getShortSumSummaryFunction();
        field.getTotalSumSummary = getTotalSumSummaryFunction();
        ... (or some other way, like storing the functions directly on the ListGrid, or on a subclass of ListGrid, or being defined in some external object like a custom SimpleType, etc)

        Then you can have your custom methods on the field simply call this method within its body - something like this:
        Code:
        function getFundAssetSumSummaryFunction(returnAll) {
            
            // returnAll available via closure
            // 
            return function (records, field) {
                var results = [];
                if (returnAll) {
                    results.push(field.getLongSumSummary(records,field));
                    results.push(field.getShortSumSummary(records,field));
                }
                results.push(field.getTotalSumSummary(records,field));
                return results;
            }
         }
        }
        And
        Code:
        field.getGridSummary = getFundAssetSumSummaryFunction(true);
        field.getGroupSummary = getFundAssetSumSummaryFunction();
        This is 'pseudo code' by the way to demonstrate the concept - we haven't actually run it and we don't have your getLongSumSummaryFunction et al functions to test your actual usage, but it should be simple to refactor taking this approach.

        If this doesn't work for any reason let us know, perhaps with a simple runnable example based off the feature explorer grid summaries sample and we'll take another look.

        Regards
        Isomorphic Software

        Comment


          #5
          Thank you! Works great. Problem solved!

          Comment

          Working...
          X