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

coordinate editing (ability to add more than one row at a time) #434

Closed
jdkent opened this issue May 15, 2023 · 3 comments · Fixed by #463
Closed

coordinate editing (ability to add more than one row at a time) #434

jdkent opened this issue May 15, 2023 · 3 comments · Fixed by #463

Comments

@jdkent
Copy link
Member

jdkent commented May 15, 2023

No description provided.

@jdkent
Copy link
Member Author

jdkent commented May 16, 2023

would this require batching functionality?
I can work on adding batch endpoints to help facilitate.

@nicoalee
Copy link
Collaborator

nicoalee commented May 18, 2023

@jdkent Nope, the backend already supports the ability to add multiple points at once. There is a case where multiple rows are added: if you try and paste at the bottom of the table, the table will automatically add multiple rows to accommodate the paste.

If we want to add the ability to right click on the table and insert multiple rows, I could add some sort of option in the right click menu that says "insert 4 rows" or something like that. Would that be an acceptable solution?
(https://forum.handsontable.com/t/how-to-add-multiple-new-rows/1347/2)

@jdkent
Copy link
Member Author

jdkent commented May 18, 2023

yeah, that could work, here is a solution chatGPT suggested for a variable number of rows (modified based on the example you posted):

document.addEventListener("DOMContentLoaded", function() {

  function getData() {
    return [
      ['', 'Kia', 'Nissan', 'Toyota', 'Honda', 'Mazda', 'Ford'],
      ['2012', 10, 11, 12, 13, 15, 16],
      ['2013', 10, 11, 12, 13, 15, 16],
      ['2014', 10, 11, 12, 13, 15, 16],
      ['2015', 10, 11, 12, 13, 15, 16],
      ['2016', 10, 11, 12, 13, 15, 16]
    ];
  }

  var
    example3 = document.getElementById('example3'),
    settings3,
    hot3;

  settings3 = {
    data: getData(),
    rowHeaders: true,
    colHeaders: true
  };
  hot3 = new Handsontable(example3, settings3);

  hot3.updateSettings({
    contextMenu: {
      items: {
        "row_above": {
          name: 'Add rows above',
          callback: function(key, options) {
            var numRows = parseInt(prompt("Enter the number of rows to add above:", "1"));
            if (isNaN(numRows) || numRows < 1) {
              return;
            }
            hot3.alter('insert_row', hot3.getSelected()[0], numRows);
          }
        },
        "row_below": {
          name: 'Add rows below',
          callback: function(key, options) {
            var numRows = parseInt(prompt("Enter the number of rows to add below:", "1"));
            if (isNaN(numRows) || numRows < 1) {
              return;
            }
            hot3.alter('insert_row', hot3.getSelected()[0]+1, numRows);
          }
        }
      }
    }
  })

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants