How to get database ID?

Tags: #<Tag:0x00007f8b23cbf5b0>

Hello support,

I am using angular wrapper.

My starting point of development is this example https://stackblitz.com/edit/handsontable-angular

I am enable to bind with my mongoDB.

In above example, for hotInstance, I get only changes but not the value of my mongoDB _id. Would you please suggest how to get _id value in hotInstance?

And which is better to start project wrapper or pure javascript?

Best Regards,
Damanjeet

Hi Damanjeet,

If you work with Angular the use of the wrapper is a good choice. If you want to learn Handsontable and do not have a project yet, then I recommend trying the vanilla version (skip the wrappers).

Handsontable to understand and convert data to a table needs to get data is certain structure. We support arrays of objects and arrays of arrays. You can both pass as a JSON.parse(you_file).
If you need to update it once it is loaded you have two possible ways

  • All data
    loadData() method
    updateSettings > data

  • Data per cell
    setDataAtCell() - for arrays
    setDataAtRowProp - for objects

When you get to the point where everything is set and users are changing data then you can use this tutorial https://handsontable.com/docs/7.4.2/tutorial-load-and-save.html to update your database with changes.

Thank you very much for explanation.

In wrapper Hot-table, what is an alternative or method of getDataAtRow(rowThatHasBeenChanged)?

Javascript example https://jsfiddle.net/handsoncode/6jhchwer/
I am looking for similar method for hot-table wrapper.

API stays the same for vanilla and wrappers so all the methods that can be used are in the documentation https://handsontable.com/docs/7.4.2/tutorial-introduction.html
Once you get access to the instance of Handsontable you can call all core methods, like

your_instance.countRows() (- returns number of rows)
your_instance.getDataAtCell(row_index, column_index)

and the methods that are available from plugins, like

your_instance.getPlugin(‘columnSorting’).sort() (- sorts the table, uses columnSorting plugin access)
your_instance.getPlugin(‘manualRowMove’).moveRow(row_index, target_index) (- uses the manualRowMove plugin to move a row to a certain index)

Here https://handsontable.com/docs/7.4.2/frameworks-wrapper-for-angular-hot-reference.html is an example that shows how to get the access to instance using Angular wrapper

Thank you. Its solves my problem.

Great. Thank you for confirmation.

Feel free to open a new ticket when needed.