Dictionary data source

Tags: #<Tag:0x00007f8b1db53218>

Hello,

My data structure is a dictionary that looks like this:

Screenshot%20from%202021-05-19%2013-04-28

Question: Is there any to use this data structure as it is, with the letters as keys?

Currently the only way I’m able to load this data into a handsontable is to convert it to an array of dictionaries by pushing each value object into an empty array, like so:

Screenshot%20from%202021-05-19%2013-07-20

For reference, my HTML looks like:

Screenshot%20from%202021-05-19%2013-05-37

Thanks

Hi @bluefrogjam

you can for example use columns option, then it could look like this https://jsfiddle.net/handsoncode/zayhxw43/ (it depends on what result you’d like to get)

Thanks for your response, @aleksandra_budnik, that’s very good to know that I can reference the data using a dot operator if needed.

However, is it possible to get a result that looks like this:

Screenshot%20from%202021-05-20%2009-28-55

from the dictionary data as before:

dictionaries = {
‘f’: {pmz: 200, ri: 300, name: ‘F’},
‘a’: {pmz: 100, ri: 200, name: ‘A’},
‘b’: {pmz: 150, ri: 250, name: ‘B’},
‘c’: {pmz: 200, ri: 300, name: ‘C’},
‘d’: {pmz: 200, ri: 300, name: ‘D’},
‘e’: {pmz: 200, ri: 300, name: ‘E’}
};

In this example as in the screenshot above, the keys for each entry don’t matter here; ‘f’, ‘a’, and ‘b’ could be ‘x’, ‘y’, and ‘z’, etc.

I know I could push the data into a new array and display that in my table, like so:

this.instance = this.registerer.getInstance(‘hot’);
let arr = [];
for (let key in this.dictionaries) {
arr.push(this.dictionaries[key]);
}
this.instance.loadData(arr);

But I was wondering if I didn’t have to do this step of cycling through the data and making a new object, in order to save time. I’ll be downloading this data from an API, and the length of the dictionary can vary and be very large.

Thanks.

With that structure of data, it can be hard to use columns or schemas. Even if we’d be able to find a hack to display the data as desired, you might be experiencing some issues within plugins. So, in this case, I recommend using the array converter that you mentioned above.

Ok, thank you for the advice.