Hi;
I’m testing the your handsontable plugin for Vue. What i’m trying to do is, having a set of data, I want to have 1 Row Totals which SUM all rows from a specific column and 1 Column Totals which SUM all columns data for each row.
I got the Row Totals using the columnSummary plugin.
Could you help me to know, how can I get the Column Totals?. I’m trying using the afterChange event, but always I’m getting the row[0], this is because the last change is the columnSummary. If I delete the code to columnSummary, I can get the coords of cell that is being changed, but I need to have both Totals.
This is part of my code.
Thanks in advance
******* Vuex Store File *******
const state = {
columnSummary: [],
afterChange: function(changes, source) {
if (changes !== null) {
console.log("source: " + source);
console.log("changes.length: " + changes.length);
changes.forEach(([row, col, oldValue, newValue]) => {
// Some logic…
console.log("changes[row]: " + JSON.stringify(changes[row]));
console.log("changes: " + JSON.stringify(changes));
// this.$store.commit(‘updateData’, this.hotRef.getSourceData());
});
}
}
}
const getters = {
hotSettings(state) { return state.hotSettings; }
}
const mutations = {
setHotSettings(state, updateObj) { state.hotSettings[updateObj.prop] = updateObj.value; }
}
export default {
state,
getters,
mutations
}
********* Vue Component File ***********
export default {
data: function() {
let oData = {
nestedHdrs: []
}
return oData;
},
components: {
HotTable
},
computed: {
hotSettings: {
get() { return this.$store.getters.hotSettings; },
set(value) { this.$store.commit(‘setHotSettings’, value); }
}
},
created() {
this.tblRows = [];
this.nestedHdrs = [];
this.hotSettings.nestedHeaders = [];
//If I comment this code, I can get the row that is being modified by the user
//But with this code, I always get the row 0, that is the SUM row
for (let i = this.initFields; i < this.hotSettings.columns.length; i++) {
let obj = {
destinationRow: 0,
destinationColumn: i,
reversedRowCoords: false,
type: 'sum',
forceNumeric: true
}
this.hotSettings.columnSummary.push(obj);
}
}
}