如何在ui-grid中刷新一行?

时间:2016-01-22 13:23:05

标签: javascript angularjs angular-ui-grid

我正在尝试刷新在ui-grid而不是整个表格中编辑的行。

所以我的业务案例是我在网格中编辑一行,触发一个休息调用,我想从网格中更新该特定行。

休息呼叫成功:

// in server.js
Meteor.publish("userData", function () {
    return Meteor.users.find(
        {"_id": { "$ne": this.userId }}, 
        {fields: {emails: 1, profile: 1}}
    );
});

// in client.js
Meteor.subscribe("userData");

也可以使用:

   $http.put(representation.getLink('reports').href, {
         changes: manualModifications,
         comment: comment
    }).success(function(updatedEntities) {
        for (var i = 0; i < updatedEntities.length; i++) {
           angular.forEach(controller.gridOptions.data, function(entity) {
                if (updatedEntities[i].factId === entity.factId) {
                    entity.value = updatedEntities[i].value;
                    entity.dataOrigin = updatedEntities[i].dataOrigin;
                    entity.isDirty = false;
                }
           });
        }
        controller.gridApi.core.refresh();
   });

这只更新网格内的行,但仍会刷新所有行。

我查看了网格api,但我找不到这样做的东西。

我在想,因为我在forEach循环中引用了一个网格行,所以应该只能更新那一行。

1 个答案:

答案 0 :(得分:0)

根据您进行REST调用的方式(直接使用JQuery,XHR等),您可能需要调用$scope.$digest()以使其在摘要周期中恢复正常。