我使用ngHandsontable角指令来表示手柄。我成功地显示了数据,但我很难访问修改过的行,以便将数据发送到DB。
我尝试绑定afterChange回调,但是索引在列排序之后似乎是关闭的。(显示表上显示的行的索引,而不是在dataSource中)
我想知道保存ngHandsontable数据的最佳实践是什么,或者我应该如何访问API,如getData方法或columnSorting属性
-非常感谢你的帮助!-马可
发布于 2015-02-17 18:31:29
最后,我使用afterInit事件获取实例,然后在进一步的事件(如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给我这个提示。
发布于 2015-02-17 20:33:57
我只是用这种逻辑来解决这个问题:
post: function postLink(scope, iElement, iAttrs, controller) {
var hotDiv = iElement.find("div[hot-table]")
var hotInstance = hotDiv.isolateScope().hotInstance;
hotInstance.addHook('afterLoadData', function(){
console.log("loaded data");
});
}发布于 2017-07-02 19:32:09
只需在控制器中使用视图模型
var vm = this;然后,您可以调用此视图模型的任何核心可处理方法,如下
this.getCell()
this.getSourceDataAtRow()https://stackoverflow.com/questions/28330340
复制相似问题