使用nghandsontable访问handsonable方法/属性 [英] Access handsontable methods/properties using nghandsontable

查看:207
本文介绍了使用nghandsontable访问handsonable方法/属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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)

我想知道保存ngHandsontable数据的最佳做法是什么,或者应该像getData方法或columnSorting属性那样访问API

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

推荐答案

我最终使用afterInit事件获取实例,然后在诸如afterChange之类的其他事件中调用方法.

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

这是我的代码的样子:

afterInit: function() {
        $scope.hot.instance = this;
    }

然后:

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

非常感谢Bricktop给我的提示.

Thanks a lot to Bricktop for giving me the hint.

这篇关于使用nghandsontable访问handsonable方法/属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆