komarovalexander / ka-table

Lightweight MIT React Table component with Sorting, Filtering, Grouping, Virtualization, Editing and many more
http://ka-table.com
MIT License
769 stars 56 forks source link

Display summary on group row #349

Closed mschunke closed 11 months ago

mschunke commented 11 months ago

Hello, thanks for the great job with this library!

I"m trying to build an income statement report, which requires the group summaries to be displayed on the group row (on top of the group instead of the end of it). Is there a way to easily do that?

I tried using groupCell custom component, but I don't have access to the columns' values.

Any thoughts?

komarovalexander commented 11 months ago

Hi, can I ask you to provide a stackblitz example? To see what you wanna reach, what way, and what you miss to do that

mschunke commented 11 months ago

@komarovalexander thanks for the prompt reply. I don't have a stackblitz, but I want something like this: image

And I can do what I want with groupSummaryCell but not with groupCell, because there isn't the groupData prop to it.

childComponents={{
  groupSummaryCell: {
    content: ({ groupData, column }) => {
      if (column.dataType === DataType.Number && typeof value === "number") {
        return <div className="text-right">{getAccountingValue(value, false)}</div>;
      }
      return <div>{value}</div>;
    },
  },
}
komarovalexander commented 11 months ago

Hi @mschunke I got it. One solution as you already found is to have summary for the group at the end https://komarovalexander.github.io/ka-table/#/grouping-summary

but in v8.4.0 I also added groupItems and columns to the GroupRow https://github.com/komarovalexander/ka-table/pull/350 so you can also customize group row content based on this data.

mschunke commented 11 months ago

Hi @komarovalexander thank you so much for the quick update! It's working as expected, thank you!