Get Data From Blank Handsontabe

Tags: #<Tag:0x00007f51c731b148> #<Tag:0x00007f51c731af68>

I have a blank Handsontable that will be provided to users to collect information that needs to be in a structured format. After the user has entered data, I want to get the data from the Handsontable in the “Array of Objects” format. All your examples that get data in the “Array of Objects” format start with Handsontable already pre-populated with data to start. How do I do the same when starting with a blank Handsontable?

Example provided at the fiddle:

JSFiddle - Code Playground

Hi @ptownbro

I have the example with empty values, but with array of objects data structure: https://jsfiddle.net/pze41bL0/ Would that meet your requirements?

Yes. Thank you. However, I have two follow-up questions if I may.

  1. Is this the only option? I was going to actually do this, but it seemed weird that I would have to pre-populate the table with blanks.

  2. Is it possible to use a configuration option, like “startRows” for example, to set the number of default rows? To explain further, in your example, you loaded 5 blank rows of data. Could you load 1 blank row of data and then set the somehting like “startRows” to 10 and have 10 rows show?

@ptownbro

Answering both questions - yes it is possible. My example represents your requirement about certain data structure. In this case, the array of objects. Leaving the data object empty and setting up the default number of rows and columns will not have such structure. This always will need to be predefined.

@ptownbro, they also have minRows, https://handsontable.com/docs/javascript-data-grid/api/options/#minrows. Hopefully, that will help.

Thanks everyone! You can close the topic.

1 Like