使用nghandsontable访问handsonable方法/属性 [英] Access handsontable methods/properties using nghandsontable
问题描述
我正在使用 ngHandsontable Handsontable .我设法成功显示了数据,但是我正在努力访问已修改的行,以便可以将数据发送到数据库.
我尝试绑定afterChange回调,但是索引在列排序后似乎已关闭. (显示表中显示的行的索引,而不显示在dataSource中)
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屋!