Announcement

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

    SimpleType.registerSummaryFunction() where is it?

    Hi,

    I'm looking into creating summary functions for our custom types.
    I got it working by setting the summary function explicitly in code on the datasourcefield (setSummaryFunction).
    However, this is ok for "proof of concept" purposes but now I want to add a generic summary function that deals with all our simple types.

    Looking in the documentation I found the below extract...
    In code this API is nowhere to be found?

    Originally posted by SmartClient reference 8.0
    void SimpleType.registerSummaryFunction() (functionName, method)

    Registers a new summaryFunction by name.
    After calling this method, developers may specify the name passed in as a standard summaryFunction (for example in ListGridField.summaryFunction).

    Parameters:
    functionName - type: String
    name for the newly registered summaryFunction
    method - type: function
    New summary function. This function should take 2 parameters - records: an array of records for which a summary must be generated, and field: a field definition - and return a summary value for the field.
    ==== Update =====

    Looking into this a bit further, I'm getting confused.
    On the DataSourceField level, you can define only ONE SummaryFunction?
    Shouldn't this be an array? I mean how do you define the different SummaryFunction for each type (AVG, SUM, COUNT, MAX, MIN, etc.)?

    Thanx
    Bart
    Last edited by bade; 3 Apr 2011, 23:50.

    #2
    Could you please answer these questions?

    Comment


      #3
      DataSourceField.summaryFunction allows you to specify the summary function to use by default for the dataSource field - so this can be either a SummaryFunctionType [AVG, MIN, etc] or a custom SummaryFunction.

      This will be used in the grid and group summary by default in ListGrids bound to this dataSource, for this field, and may be overridden at the ListGrid level for either grid or group summaries.

      The standard SummaryFunctionTypes are only applicable to specified field types in certain cases - for example while COUNT can be applied to any set of data, AVG or SUM only applies to numeric data.

      The SimpleType.registerSummaryFunction API is currently SmartClient only (Not yet present in SmartGWT), but we're adding this right now and will let you know when it has been added and exactly what the SGWT APIs are.

      The concept here is that you define a custom summary function and give it a name or ID such that it can be reused across fields / components by simply referring to the name, rather than having to reimplement the logic wherever it is to be used. In a way this API allows you to extend the set of "standard" summary functions with your own custom calculations.

      Comment


        #4
        The changes have now been made to our mainline codebase and should show up in the next nightly build.
        The APIs should be self explanatory but in short
        - you can register a new, reusable SummaryFunction via the static SimpleType.registerSummaryFunction method.
        - you can apply this to a DS or LG field via setSummaryFunction() [passing in the name you registered under].
        - you can apply a standard SummaryFunctionType, or a newly registered summary function to a SimpleType as a default by calling the static SimpleType.setDefaultSummaryFunction(typeName, summaryFunction) methods. (You will need to explicitly call SimpleType.register() on your simple type before doing this to ensure it's been registered by name).
        - you can also call default summary function behavior via the static SimpleType.applySummaryFunction() method

        Regards
        Isomorphic Software

        Comment


          #5
          Thanx! I'll give it a go as soon as the nightly is ready.

          Regards,
          Bart

          Comment

          Working...
          X