Web2py app with HandsOnTables: alter('row_above') and alter('row_below) don't work.

8 views
Skip to first unread message

JohnZ

unread,
Mar 10, 2016, 8:01:20 PM3/10/16
to Handsontable
I'm using HandsOnTables with a web2py app. All seems to work well, except that I cannot get the alter('row_above') or alter('row_below') to work. In the context menu, they are grayed out, and if I invoke them in code, nothing happens. Some digging around turned up a post (somewhere) that these two don't work unless the data source is an array. In fact, when I replace the web2py data source with an array in the HTML for the view, the two add row commands do work as advertised.

The two alter functions work with this:

$(document).ready(function() {

  var data = [
  {
     "id":1,
  "last_name":"Abbrederis",
     "first_name":"Jason",
     "pos":"WR"

  },
  {
     "id":2,
  "last_name":"Abbrederis",
     "first_name":"Jason",
     "pos":"WR"
  },
  {
     "id":3,
  "last_name":"Adams",
     "first_name":"Davante",
     "pos":"WR"
  }
  ];


  var hotElement = document.getElementById('list');
      datatable = new Handsontable(hotElement, {
        data: data,
   <...snip rest of table configuration...>

They do not work with this:

var data = {{=XML(injuries.json())}}

  var hotElement = document.getElementById('list');
  datatable = new Handsontable(hotElement, {
        data: data,
   <...snip rest of table configuration...>

Any ideas as to how to insert a row in this web2py-based app will be greatly appreciated!



JohnZ

unread,
Mar 21, 2016, 7:46:25 PM3/21/16
to Handsontable
The problem had nothing to do with web2py or HandsOnTables; it was my misunderstanding about how maxRows works. I had maxRows set to a value and the dataset had more rows than the maxrows value. So, of course, no more rows can be added to the table, and the add_row functions don't work.  By removing the maxrows value, it worked as it should. My mistake...


Reply all
Reply to author
Forward
0 new messages