Announcement

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

    Get the group summary rows from a ListGrid

    I am currently evaluating SmartClient for use in our hosted application, and cannot seem to find any examples in the documentation and the API is not giving me any clues.

    I am trying to create a charting UI to add on top of the grid. It works very well if the grid is not grouped. However, to offer clients more flexibility, I want to allow them to perform a group and build a chart from the grouped data using a summary field.

    I can group and add summary fields, but I cannot seem to find anything on how to get the summary information out of the grid. I basically need to send my chart class a new data set which is derived from the current grid, the series will be the group and the values will be one of the summary fields that are already configured. I will create this new data set at runtime, after the user selects some options from the UI.

    So I need to get the following information:
    - the group by field (I do this with .getGroupByFields())
    - all the summary fields that are available for the group
    - a way to build a data set (group1, summaryvalue),(group2,summaryvalue),etc.

    Any help or pointers to the API is greatly appreciated. SmartClient offers everything else we need to do, but this is the last requirement I need to prototype.

    #2
    It's a little unclear if by "summary fields" you mean the data generated via listGrid.showGridSummary vs user-defined summary fields created in a SummaryBuilder, however, if you search for "summary" you can see all kinds of accessors for calculated summary values. Also, listGrid.groupTree gives you the Tree formed by the grid when grouping if you need to traverse that.

    Comment


      #3
      So traversing the tree works to get default summary values. What I do is let the user select the aggregate function at runtime:

      var column = _gridObject.getField("columnName");
      column.summaryFunction = "avg" | "sum" | "max" etc.

      This works and the summaries are displayed in the corresponding column. I allow the user to select any column that makes sense.

      I cannot see in the tree where these custom functions are stored, or how to access them easily.

      The alternative is to traverse the tree to get the groups, then perform the aggregate function myself to get the data. Not the most elaborate approach, but it will work.

      I was hoping it would be as easy as an API call like getSummaryRecords(), and the data returned would give me the group value, and each group with one record representing the summary data in each fieldItem.

      Comment


        #4
        The Tree is the data, and summary functions are not data, so they are not in the Tree.

        Take a look at the various methods returned by the search for "summary" (see link in previous post). These provide the results of the summary functions in various formats that you can use.

        Comment

        Working...
        X