重新加载数据后如何刷新UI-Grid布局 [英] How to refresh UI-Grid layout after reloading data

查看:434
本文介绍了重新加载数据后如何刷新UI-Grid布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Angular UI-Grid有疑问( http://ui-grid.info/ ).网格是在用户单击按钮后出现的模态窗口中实现的. 服务以这种方式工作:用户选择要准备的数据集并单击按钮.单击按钮后,网站发送请求休息服务以接收数据.接收到数据后,模态与表格一起显示.列数取决于用户请求的数据.

I have a problem with Angular UI-Grid (http://ui-grid.info/). Grid is implemented in modal window that appears after user clicks button. Service works that way: User selects data set to prepare and clicks button. After clicking button website sends request to rest service to receive data. After receiving data modal with table is shown. Columns count depends on data requested by user.

问题在于,用户使用此表更改列宽并关闭模式后,UI-Grid会记住"用户剩余的列宽.如果那样的话,用户将选择另一组数据,我正在清理GridOptions对象,并在收到数据后再次填充它.问题是行宽保持在以前的状态. 到目前为止,我已经尝试过:

The problem is that after user changes columns width and close modal with this table UI-Grid 'remembers' this column width that user left. If then user will select another set of data I am cleaning GridOptions object and fill it once again after data is received. The problem is that row width stays in previous state. I tried so far:

  • 使用apis core.refresh()方法-在调试时,我可以看到 方法会触发一些事件,但不会对我的网格产生影响,
  • 删除整个DOM节点并再次附加它,然后再接收到具有新数据的响应
  • 各种不同的黑客试图使用在Grid API中找到的许多方法-完全没有成功.
  • using apis core.refresh() method - while debugging I can see that this method fires some event but no effect on my grid,
  • remove whole DOM node and append it again before receiving response with new data
  • various different hacks trying to use many methods found inside grid api - no success at all.

很抱歉,我无法重现这一点,但是我很难匹配我的情况.

I am sorry that I am unable to reproduce this in any fiddle but it would be really difficult I am afraid to match my case.

任何帮助将不胜感激.谢谢

Any help would be very appreciated. Thanks

ps.它也适用于我的另一个表,用户可以在其中固定和隐藏列.接收到新数据后,固定/隐藏列将保持隐藏/固定.而且不酷.

ps. it also applies to my another table where user can pin and hide columns. Pinned/hidden columns remains hidden/pinned after receiving brand new data. And it is not cool.

推荐答案

将数据设置到网格后,您应该调用它-

Once you set the data to the grid, you should be calling this -

gridApi.core.notifyDataChange( uiGridConstants.dataChange.ALL)  

从文档中

通知我们发生了数据更改,已在公共api中使用 让用户告诉我们他们何时更改了数据或其他事件 我们的手表无法拾起

Notifies us that a data change has occurred, used in the public api for users to tell us when they've changed data or some other event that our watches cannot pick up

notifyDataChange告诉框架选项或columnDefs之一已更改.

notifyDataChange tells the framework that one of the options or columnDefs has been changed.

检出此线程

这篇关于重新加载数据后如何刷新UI-Grid布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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