Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instantiate Handsontable with no data

Tags:

handsontable

Seems like a simple task yet I haven't found a simple solution yet. My data sometimes comes as an empty array so that the user can start working off of an empty table (except for the headers). The table has a minSpareRows:1 so I was hoping the table would appear with that spare row and nothing else but instead it goes entirely blank.

Any ideas on how to instantiate a table with just the spare row and the column headers?

Things I've tried include manually inserting a row if the data array is empty however this leads to there being an empty row plus a spare row.

like image 640
ZekeDroid Avatar asked Jan 20 '15 16:01

ZekeDroid


1 Answers

You can use minRows and minCols to instantiate an empty Handsontable instance. Also, the data arguments expects an array of arrays, so in your case when you receive an empty array, just wrap it in another one:

data : Array of Arrays (default [ [] ]) 

Here's a working JSFiddle.

like image 116
Milan Milanov Avatar answered Nov 12 '22 23:11

Milan Milanov