{
    "componentChunkName": "component---src-templates-doc-page-jsx",
    "path": "/react-data-grid/aggregation-other/",
    "result": {"data":{"markdownRemark":{"htmlAst":{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This section covers areas of aggregation that don't fit within the other sections of the documentation."}]},{"type":"element","tagName":"h2","properties":{"id":"default-aggregation-function","style":"position:relative;"},"children":[{"type":"text","value":"Default Aggregation Function"},{"type":"element","tagName":"a","properties":{"href":"#default-aggregation-function","ariaLabel":"default aggregation function permalink","className":["docs-header-icon","after"]},"children":[{"type":"element","tagName":"svg","properties":{"id":"icon","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 32 32"},"children":[{"type":"element","tagName":"path","properties":{"d":"M29.25,6.76a6,6,0,0,0-8.5,0l1.42,1.42a4,4,0,1,1,5.67,5.67l-8,8a4,4,0,1,1-5.67-5.66l1.41-1.42-1.41-1.42-1.42,1.42a6,6,0,0,0,0,8.5A6,6,0,0,0,17,25a6,6,0,0,0,4.27-1.76l8-8A6,6,0,0,0,29.25,6.76Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M4.19,24.82a4,4,0,0,1,0-5.67l8-8a4,4,0,0,1,5.67,0A3.94,3.94,0,0,1,19,14a4,4,0,0,1-1.17,2.85L15.71,19l1.42,1.42,2.12-2.12a6,6,0,0,0-8.51-8.51l-8,8a6,6,0,0,0,0,8.51A6,6,0,0,0,7,28a6.07,6.07,0,0,0,4.28-1.76L9.86,24.82A4,4,0,0,1,4.19,24.82Z"},"children":[]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When columns are dragged to the "},{"type":"element","tagName":"b","properties":{},"children":[{"type":"text","value":"Values"}]},{"type":"text","value":" section of the "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.5/tool-panel-columns/"},"children":[{"type":"text","value":"Columns Tool Panel"}]},{"type":"text","value":" they are\nassigned the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"sum"}]},{"type":"text","value":" aggregation function by default. The default aggregation function can be overridden on a per-column\nbasis using the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"defaultAggFunc"}]},{"type":"text","value":" column property."}]},{"type":"element","tagName":"snippet","properties":{},"children":[{"type":"text","value":"\nconst gridOptions = {\n    columnDefs: [\n        {\n            field: 'gold',\n            // allows column to be dragged to the 'Values` section of the Columns Tool Panel \n            enableValue: true,\n            // use 'avg' as the default agg func instead of 'sum'  \n            defaultAggFunc: 'avg',\n        },\n    ]\n}\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The following example demonstrates overriding the default agg function. Note the following:"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"b","properties":{},"children":[{"type":"text","value":"Gold"}]},{"type":"text","value":" column is configured with "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"defaultAggFunc"}]},{"type":"text","value":" set to "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"avg"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Drag the "},{"type":"element","tagName":"b","properties":{},"children":[{"type":"text","value":"Gold"}]},{"type":"text","value":" column to the "},{"type":"element","tagName":"b","properties":{},"children":[{"type":"text","value":"Values"}]},{"type":"text","value":" section of the Columns Tool Panel and note that it is assigned the 'avg' function. "}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"b","properties":{},"children":[{"type":"text","value":"Silver"}]},{"type":"text","value":" column is configured to use a custom aggregation function as its default. Drag the "},{"type":"element","tagName":"b","properties":{},"children":[{"type":"text","value":"Silver"}]},{"type":"text","value":" column to the "},{"type":"element","tagName":"b","properties":{},"children":[{"type":"text","value":"Values"}]},{"type":"text","value":" section and note that it is assigned the function "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"mySum"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Dragging the "},{"type":"element","tagName":"b","properties":{},"children":[{"type":"text","value":"Bronze"}]},{"type":"text","value":" column will use "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"sum"}]},{"type":"text","value":" as the default. "}]},{"type":"text","value":"\n"}]},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"grid-example","properties":{"title":"Default Aggregation Function","name":"default-aggregation-function","type":"generated","options":"{ \"enterprise\": true, \"exampleHeight\": 655, \"modules\": [\"clientside\", \"rowgrouping\", \"menu\", \"columnpanel\", \"filterpanel\"] }"},"children":[]}]},{"type":"element","tagName":"div","properties":{"className":["custom-block","note"]},"children":[{"type":"element","tagName":"div","properties":{"className":["custom-block-body"]},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Note that unlike "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"aggFunc"}]},{"type":"text","value":" you can't pass a custom aggregation function directly to "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"defaultAggFunc"}]},{"type":"text","value":",\nas demonstrated in the previous example, it must be registered first. See "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.5/aggregation-custom-functions#registering-custom-functions"},"children":[{"type":"text","value":"Registering Custom Functions"}]},{"type":"text","value":" for how to do this."}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"restricting-aggregation-functions","style":"position:relative;"},"children":[{"type":"text","value":"Restricting Aggregation Functions"},{"type":"element","tagName":"a","properties":{"href":"#restricting-aggregation-functions","ariaLabel":"restricting aggregation functions permalink","className":["docs-header-icon","after"]},"children":[{"type":"element","tagName":"svg","properties":{"id":"icon","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 32 32"},"children":[{"type":"element","tagName":"path","properties":{"d":"M29.25,6.76a6,6,0,0,0-8.5,0l1.42,1.42a4,4,0,1,1,5.67,5.67l-8,8a4,4,0,1,1-5.67-5.66l1.41-1.42-1.41-1.42-1.42,1.42a6,6,0,0,0,0,8.5A6,6,0,0,0,17,25a6,6,0,0,0,4.27-1.76l8-8A6,6,0,0,0,29.25,6.76Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M4.19,24.82a4,4,0,0,1,0-5.67l8-8a4,4,0,0,1,5.67,0A3.94,3.94,0,0,1,19,14a4,4,0,0,1-1.17,2.85L15.71,19l1.42,1.42,2.12-2.12a6,6,0,0,0-8.51-8.51l-8,8a6,6,0,0,0,0,8.51A6,6,0,0,0,7,28a6.07,6.07,0,0,0,4.28-1.76L9.86,24.82A4,4,0,0,1,4.19,24.82Z"},"children":[]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"By default, all functions are available to all value columns. To restrict the aggregation functions available on a value\ncolumn, use the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"allowedAggFuncs"}]},{"type":"text","value":" column property as shown below:"}]},{"type":"element","tagName":"snippet","properties":{},"children":[{"type":"text","value":"\nconst gridOptions = {\n    columnDefs: [\n        {\n            field: 'gold', \n            aggFunc: 'sum',\n            // restricts agg functions to be: `sum`, `min` and `max`\n            allowedAggFuncs: ['sum', 'min', 'max'],\n        }\n    ]\n}\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The following example demonstrates restricting the aggregation functions. Note the following:"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"b","properties":{},"children":[{"type":"text","value":"Gold"}]},{"type":"text","value":" column is configured with "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"allowedAggFuncs"}]},{"type":"text","value":" set to "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"['sum', 'min', 'max']"}]},{"type":"text","value":" and only displays these functions in the drop-down list in the "},{"type":"element","tagName":"b","properties":{},"children":[{"type":"text","value":"Values"}]},{"type":"text","value":" section column to the of the Columns Tool Panel."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The "},{"type":"element","tagName":"b","properties":{},"children":[{"type":"text","value":"Silver"}]},{"type":"text","value":" column shows all available agg functions as it hasn't been restricted."}]},{"type":"text","value":"\n"}]},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"grid-example","properties":{"title":"Restricting Aggregation Functions","name":"restricting-aggregation-functions","type":"generated","options":"{ \"enterprise\": true, \"exampleHeight\": 655, \"modules\": [\"clientside\", \"rowgrouping\", \"menu\", \"columnpanel\", \"filterpanel\"] }"},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"aggregation-api","style":"position:relative;"},"children":[{"type":"text","value":"Aggregation API"},{"type":"element","tagName":"a","properties":{"href":"#aggregation-api","ariaLabel":"aggregation api permalink","className":["docs-header-icon","after"]},"children":[{"type":"element","tagName":"svg","properties":{"id":"icon","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 32 32"},"children":[{"type":"element","tagName":"path","properties":{"d":"M29.25,6.76a6,6,0,0,0-8.5,0l1.42,1.42a4,4,0,1,1,5.67,5.67l-8,8a4,4,0,1,1-5.67-5.66l1.41-1.42-1.41-1.42-1.42,1.42a6,6,0,0,0,0,8.5A6,6,0,0,0,17,25a6,6,0,0,0,4.27-1.76l8-8A6,6,0,0,0,29.25,6.76Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M4.19,24.82a4,4,0,0,1,0-5.67l8-8a4,4,0,0,1,5.67,0A3.94,3.94,0,0,1,19,14a4,4,0,0,1-1.17,2.85L15.71,19l1.42,1.42,2.12-2.12a6,6,0,0,0-8.51-8.51l-8,8a6,6,0,0,0,0,8.51A6,6,0,0,0,7,28a6.07,6.07,0,0,0,4.28-1.76L9.86,24.82A4,4,0,0,1,4.19,24.82Z"},"children":[]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After the grid is initialised aggregations can be applied / retrieved / removed via the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"columnApi"}]},{"type":"text","value":" with the following methods:"}]},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"api-documentation","properties":{"source":"column-api/api.json","section":"valueColumns"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When the grid initialises, any column definitions that have "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"aggFunc"}]},{"type":"text","value":" set will be automatically added as a value column."}]},{"type":"element","tagName":"h2","properties":{"id":"column-headers","style":"position:relative;"},"children":[{"type":"text","value":"Column Headers"},{"type":"element","tagName":"a","properties":{"href":"#column-headers","ariaLabel":"column headers permalink","className":["docs-header-icon","after"]},"children":[{"type":"element","tagName":"svg","properties":{"id":"icon","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 32 32"},"children":[{"type":"element","tagName":"path","properties":{"d":"M29.25,6.76a6,6,0,0,0-8.5,0l1.42,1.42a4,4,0,1,1,5.67,5.67l-8,8a4,4,0,1,1-5.67-5.66l1.41-1.42-1.41-1.42-1.42,1.42a6,6,0,0,0,0,8.5A6,6,0,0,0,17,25a6,6,0,0,0,4.27-1.76l8-8A6,6,0,0,0,29.25,6.76Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M4.19,24.82a4,4,0,0,1,0-5.67l8-8a4,4,0,0,1,5.67,0A3.94,3.94,0,0,1,19,14a4,4,0,0,1-1.17,2.85L15.71,19l1.42,1.42,2.12-2.12a6,6,0,0,0-8.51-8.51l-8,8a6,6,0,0,0,0,8.51A6,6,0,0,0,7,28a6.07,6.07,0,0,0,4.28-1.76L9.86,24.82A4,4,0,0,1,4.19,24.82Z"},"children":[]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When aggregating, the column headers will include the aggregation function for the column. For example the header "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"'Bank Balance'"}]},{"type":"text","value":" will become "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"'sum(Bank Balance)'"}]},{"type":"text","value":" if you have the sum aggregation active on the column. To turn this off and display simply "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"'Bank Balance'"}]},{"type":"text","value":" then set the grid property "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"suppressAggFuncInHeader"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"api-documentation","properties":{"source":"grid-options/properties.json","section":"rowPivoting","names":"[\"suppressAggFuncInHeader\"]"},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"empty-aggregation-calls","style":"position:relative;"},"children":[{"type":"text","value":"Empty Aggregation Calls"},{"type":"element","tagName":"a","properties":{"href":"#empty-aggregation-calls","ariaLabel":"empty aggregation calls permalink","className":["docs-header-icon","after"]},"children":[{"type":"element","tagName":"svg","properties":{"id":"icon","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 32 32"},"children":[{"type":"element","tagName":"path","properties":{"d":"M29.25,6.76a6,6,0,0,0-8.5,0l1.42,1.42a4,4,0,1,1,5.67,5.67l-8,8a4,4,0,1,1-5.67-5.66l1.41-1.42-1.41-1.42-1.42,1.42a6,6,0,0,0,0,8.5A6,6,0,0,0,17,25a6,6,0,0,0,4.27-1.76l8-8A6,6,0,0,0,29.25,6.76Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M4.19,24.82a4,4,0,0,1,0-5.67l8-8a4,4,0,0,1,5.67,0A3.94,3.94,0,0,1,19,14a4,4,0,0,1-1.17,2.85L15.71,19l1.42,1.42,2.12-2.12a6,6,0,0,0-8.51-8.51l-8,8a6,6,0,0,0,0,8.51A6,6,0,0,0,7,28a6.07,6.07,0,0,0,4.28-1.76L9.86,24.82A4,4,0,0,1,4.19,24.82Z"},"children":[]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When providing either "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.5/aggregation-custom-functions#custom-aggregation-functions"},"children":[{"type":"text","value":"Custom Aggregation Functions"}]},{"type":"text","value":" or "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.5/aggregation-custom-functions#custom-full-row-aggregation"},"children":[{"type":"text","value":"Custom Full Row Aggregation"}]},{"type":"text","value":" then you will see strange calls to these functions where empty lists are provided."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The empty aggregation calls happen in the following two scenarios:"}]},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The grid has no data (usually the case when the gird is initially displayed before the application has set data). Aggregating at the root level will request an aggregation of an empty set."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The grid has groups and a filter, such that groups are empty."}]},{"type":"text","value":"\n"}]},{"type":"element","tagName":"h2","properties":{"id":"recomputing-aggregates","style":"position:relative;"},"children":[{"type":"text","value":"Recomputing Aggregates"},{"type":"element","tagName":"a","properties":{"href":"#recomputing-aggregates","ariaLabel":"recomputing aggregates permalink","className":["docs-header-icon","after"]},"children":[{"type":"element","tagName":"svg","properties":{"id":"icon","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 32 32"},"children":[{"type":"element","tagName":"path","properties":{"d":"M29.25,6.76a6,6,0,0,0-8.5,0l1.42,1.42a4,4,0,1,1,5.67,5.67l-8,8a4,4,0,1,1-5.67-5.66l1.41-1.42-1.41-1.42-1.42,1.42a6,6,0,0,0,0,8.5A6,6,0,0,0,17,25a6,6,0,0,0,4.27-1.76l8-8A6,6,0,0,0,29.25,6.76Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M4.19,24.82a4,4,0,0,1,0-5.67l8-8a4,4,0,0,1,5.67,0A3.94,3.94,0,0,1,19,14a4,4,0,0,1-1.17,2.85L15.71,19l1.42,1.42,2.12-2.12a6,6,0,0,0-8.51-8.51l-8,8a6,6,0,0,0,0,8.51A6,6,0,0,0,7,28a6.07,6.07,0,0,0,4.28-1.76L9.86,24.82A4,4,0,0,1,4.19,24.82Z"},"children":[]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If the data changes after the aggregation is done, you can tell the grid to recompute the aggregates through the API method "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"refreshClientSideRowModel('aggregate')"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"api-documentation","properties":{"source":"grid-api/api.json","section":"data","names":"[\"refreshClientSideRowModel\"]"},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"next-up","style":"position:relative;"},"children":[{"type":"text","value":"Next Up"},{"type":"element","tagName":"a","properties":{"href":"#next-up","ariaLabel":"next up permalink","className":["docs-header-icon","after"]},"children":[{"type":"element","tagName":"svg","properties":{"id":"icon","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 32 32"},"children":[{"type":"element","tagName":"path","properties":{"d":"M29.25,6.76a6,6,0,0,0-8.5,0l1.42,1.42a4,4,0,1,1,5.67,5.67l-8,8a4,4,0,1,1-5.67-5.66l1.41-1.42-1.41-1.42-1.42,1.42a6,6,0,0,0,0,8.5A6,6,0,0,0,17,25a6,6,0,0,0,4.27-1.76l8-8A6,6,0,0,0,29.25,6.76Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M4.19,24.82a4,4,0,0,1,0-5.67l8-8a4,4,0,0,1,5.67,0A3.94,3.94,0,0,1,19,14a4,4,0,0,1-1.17,2.85L15.71,19l1.42,1.42,2.12-2.12a6,6,0,0,0-8.51-8.51l-8,8a6,6,0,0,0,0,8.51A6,6,0,0,0,7,28a6.07,6.07,0,0,0,4.28-1.76L9.86,24.82A4,4,0,0,1,4.19,24.82Z"},"children":[]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Continue to the next section to learn about "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.5/tree-data/"},"children":[{"type":"text","value":"Tree Data"}]},{"type":"text","value":"."}]}]},"frontmatter":{"title":"Aggregation - Other","version":null,"enterprise":true,"sideMenu":null,"description":null},"headings":[{"id":"default-aggregation-function","depth":2,"value":"Default Aggregation Function"},{"id":"restricting-aggregation-functions","depth":2,"value":"Restricting Aggregation Functions"},{"id":"aggregation-api","depth":2,"value":"Aggregation API"},{"id":"column-headers","depth":2,"value":"Column Headers"},{"id":"empty-aggregation-calls","depth":2,"value":"Empty Aggregation Calls"},{"id":"recomputing-aggregates","depth":2,"value":"Recomputing Aggregates"},{"id":"next-up","depth":2,"value":"Next Up"}]}},"pageContext":{"frameworks":["javascript","react","angular","vue"],"framework":"react","srcPath":"/aggregation-other","pageName":"aggregation-other"}},
    "staticQueryHashes": ["1766026005","699667431","940729948"]}