AllenFang / AllenFang/react-bootstrap-table

How can I get total sum in a column about other column?

Ouverte
#2,034 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
JavaScript
Étoiles
2.2k
Forks
761
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

Hi! I'm trying to get the total sum about one column, but at the moment I could only do it this way.

```
import React from 'react';
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
import { connect } from 'react-redux';
import _ from 'lodash';

const formatName = (cell, row, extra) => {
let display = 'No disponible'; if (_.get(row, 'name')) { display = `${_.get(row, 'name')}` }
return (


{display}

)
};
const formatPrice = (cell, row, extra) => {
let display = 0; if (_.get(row, 'total')) { display = `${_.get(row, 'total')}` }

return (


{parseFloat(display).toFixed(2)}€

)
};

class ChartInventory extends React.Component {
state = {
sortName: 'name',
sortOrder: 'asc',
}

render() {
const options = {
sortName: this.state.sortName,
sortOrder: this.state.sortOrder
};

console.log('ANALYTICS ', this.props.analytics)
return (



10}
trClassName="table-row"
ref="inventoryAnalyticsTable">
Nombre
Precio





Precio Total

{_.sumBy(this.props.analytics, 'total').toFixed(2)}€



);
}
}

const mapStateToprops = state => ({
analytics: state.inventory.analytics,
});

export default connect(mapStateToprops, null)(ChartInventory);
```

And this is the result

![image](https://user-images.githubusercontent.com/44264807/47288514-c21aaf80-d5f6-11e8-91fa-390c43576128.png)

With which, I would like to be able to obtain the _"Precio Total"_(_Total Price_) data in another column

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.