Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Is there a way to calculate percentages for each row corresponding to group total #72

Open
rrameshkumar76 opened this issue Jun 27, 2019 · 2 comments

Comments

@rrameshkumar76
Copy link

rrameshkumar76 commented Jun 27, 2019

Is there a way to calculate percentages for totals columns for each row corresponding to group total

Basically if there is a way to to get the group total or the row in calculations for the level above.

If not I guess we need to pass back the parent record to the template

@rrameshkumar76
Copy link
Author

rrameshkumar76 commented Jun 28, 2019

May could do something like

renderTableBody: function (columns, rows) {
    var self = this
    var parents = new Map()
    return (
      <tbody>
      {rows.map(function (row) {
        parents.set(row._level, row)
        return (
          <tr key={row._key} className={"reactPivot-level-" + row._level}>
            {columns.map(function (col, i) {
              if (i < row._level) return <td key={i} className='reactPivot-indent' />
              var topLevelParent = parents.get(0)
              var previousLevelParent = row._level > 0 ? parents.get(row._level - 1) : topLevelParent
              return self.renderCell(col, row, topLevelParent, previousLevelParent)
            })}
          </tr>
        )

      })}
      </tbody>
    )
  },

to calculate all the parents and pass to the renderCell and from there to template methods

@Pewiz
Copy link

Pewiz commented Jan 9, 2025

Hi, I just implemented this functionality of obtaining the percentage depending on the filtered group, I leave you the repository:

Pewiz/pivotReact

I made this project with a react-pivot version called react-pivot-webpack

Sorry for the delay in responding 😂. I hope this helps you or someone else 🙌

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants