You can add a summary row to your NatTable easily by adding and configuring the SummaryRowLayer.
The Creating_a_summary_row and CalculatingGridExample examples are the best places to look at.
You can add a summary row to your NatTable easily by adding and configuring the SummaryRowLayer.
The Creating_a_summary_row and CalculatingGridExample examples are the best places to look at.
To add a summary row to your NatTable, you have to add the SummaryRowLayer to your body layer stack. As it should deal directly to the data shown in the NatTable, it should be added to the body layer close to the DataLayer. As with all layers this can easily be done with the following code snippet:
Snippet from Creating_a_summary_row example
Note that the SummaryRowLayer needs the ConfigRegistry to access the summary row specific configurations.
The next step on adding a summary row to a NatTable is to configure the content that should be showed within the summary row. This is done by ISummaryProvider that need to be configured via ConfigRegistry.
NatTable comes with three default ISummaryProvider
Snippet from Creating_a_summary_row example
To be able to configure the SummaryRowLayer in detail, it introduces two new labels for which the specific configurations can be added:
There is a DefaultSummaryRowConfiguration to configure the style and the summary formulas of the summary row. You can extend that or create your own configuration. In this configuration you should add your ISummaryProvider as you like the SummaryRowLayer to be configured.
Snippet from MySummaryRowConfig of the Creating_a_summary_row example
To reflect the summary row within the row header of a grid, you should consider using the DefaultSummaryRowHeaderDataProvider to create the DataLayer of your DefaultSummaryRowHeaderDataProvider or something custom that looks like it. Using this the row header will show incrementing line numbers for all data rows and by default the word Summary for the summary row. The DefaultSummaryRowHeaderDataProvider also has a constructor that accepts a parameter that allows you to specify your own row header label for the summary row.
Snippet from CalculatingGridLayer of the CalculatingGridExample