Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Working solution for adding rows and columns at the expected location #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions app/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class Home extends React.Component {

this.numRows = 75;
this.numColumns = 26;
this.needsDimensionUpdate = false;
}

componentDidMount() {
Expand All @@ -20,6 +21,18 @@ export default class Home extends React.Component {
rows: this.numRows,
columns: this.numColumns,
change: this.onChange,
render: () => {
if(this.needsDimensionUpdate) {
// make sure this only recreates the sheet once per dimension change
this.needsDimensionUpdate = false;

// rebuild the spreadsheet off current data
this.getSpreadsheet().fromJSON(this.getJSON());

// make sure to save to note
this.onChange();
}
},
changeFormat: this.onChange, // triggered when cell structure changes (currency, date, etc)
excelImport: (event) => {
// Excel import functionality has been disabled completely.
Expand Down Expand Up @@ -49,17 +62,13 @@ export default class Home extends React.Component {
hideRow: this.onChange,
deleteColumn: this.onChange,
deleteRow: this.onChange,
insertColumn: () => {
var workbook = this.getJSON();
workbook.columns = ++this.numColumns;
this.getSpreadsheet().fromJSON(workbook);
this.onChange();
insertColumn: (event) => {
this.numColumns += 1;
this.needsDimensionUpdate = true;
},
insertRow: (event) => {
var workbook = this.getJSON();
workbook.rows = ++this.numRows;
this.getSpreadsheet().fromJSON(workbook);
this.onChange();
this.numRows += 1;
this.needsDimensionUpdate = true;
}
});

Expand Down Expand Up @@ -111,7 +120,6 @@ export default class Home extends React.Component {
return json;
}


connectToBridge() {
var permissions = [
{
Expand Down