Skip to content

Calculated column #272

Answered by ghiscoding
muezz asked this question in Q&A
Dec 16, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

I'm not sure if you're talking about column width calculation (see docs) or if you're talking about calculating 2 cell property and show its total on another cell on the right, if that's the case then just use a Custom Formatter, the 4th and 5th arguments are columnDef and dataContext (item), you have access to the entire row item (dataContext) so you can easily calculate stuff and then use Grouping if you need to calculate group totals.

const sumFormatter: Formatter = (row, cell, val, columnDef, dataContext) => {
  const total = dataContext['price'] * dataContext['qty']; // calculate
  dataContext[columnDef.field] = total; // assign
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@muezz
Comment options

@ghiscoding
Comment options

Answer selected by muezz
@muezz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants