Marco Marco - 1 year ago 332
AngularJS Question

Access handsontable methods/properties using nghandsontable

I'm using ngHandsontable angular directive for Handsontable. I managed to show the data successfully, but I'm struggling with getting access to the modified rows so I can send the data to the db.

I tried binding the afterChange callback, but the index seems to be off after column sorting. (shows the index of the row shown on the table, not in the datasource)

I wonder what's the best practice to save ngHandsontable data or what I should do to access the api like getData method or columnSorting property

Thanks a lot for your help!
- Marco

Answer Source

I ended up using afterInit event to get the instance and then call the methods in further events like the afterChange.

This is how my code looks like:

afterInit: function() {
        $ = this;

and then:

afterChange: function (changes, source) {
        if (source != 'loadData') {          
            var hot = $;
            var dataRow = hot.getSourceDataAtRow(index)
            // .... saveChanges...

Thanks a lot to Bricktop for giving me the hint.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download