简体   繁体   English

如何在ui-grid中刷新行?

[英]How to refresh a row in ui-grid?

I am trying to refresh just the row that's been edited in the ui-grid and not the whole table. 我正在尝试仅刷新在ui网格中已编辑的行,而不是整个表。

So my business case is that I edit a row in the grid, trigger a rest call and the I want to updated just that specific row from the grid. 因此,我的业务案例是我在网格中编辑一行,触发一个REST调用,并且我想只更新网格中的该特定行。

on rest call success: 休息时呼叫成功:

   $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();
   });

works as well using: 使用以下命令也可以正常工作:

controller.gridApi.core.refreshRows();

this updating only the rows inside the grid, but still refreshes all the rows. 此操作仅更新网格内的行,但仍刷新所有行。

I have looked over the grid api but I could not find something that does this. 我查看了Grid API,但找不到能做到这一点的东西。

I am thinking that since I have a reference to a grid row inside the forEach cycle should be possible to update just that single row. 我在想,因为我在forEach周期内引用了一个网格行,所以应该可以只更新该行。

根据您执行REST调用的方式(直接使用JQuery,XHR等),您可能需要调用$scope.$digest()使其在摘要循环中恢复角度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM