• <i id='aGyxU'><tr id='aGyxU'><dt id='aGyxU'><q id='aGyxU'><span id='aGyxU'><b id='aGyxU'><form id='aGyxU'><ins id='aGyxU'></ins><ul id='aGyxU'></ul><sub id='aGyxU'></sub></form><legend id='aGyxU'></legend><bdo id='aGyxU'><pre id='aGyxU'><center id='aGyxU'></center></pre></bdo></b><th id='aGyxU'></th></span></q></dt></tr></i><div id='aGyxU'><tfoot id='aGyxU'></tfoot><dl id='aGyxU'><fieldset id='aGyxU'></fieldset></dl></div>

      <small id='aGyxU'></small><noframes id='aGyxU'>

    1. <tfoot id='aGyxU'></tfoot>
          <bdo id='aGyxU'></bdo><ul id='aGyxU'></ul>
        <legend id='aGyxU'><style id='aGyxU'><dir id='aGyxU'><q id='aGyxU'></q></dir></style></legend>

        Vaadin 8.5.1- 行更新后刷新网格

        Vaadin 8.5.1- Refresh grid after row update(Vaadin 8.5.1- 行更新后刷新网格)
      1. <tfoot id='5KNgP'></tfoot>

      2. <i id='5KNgP'><tr id='5KNgP'><dt id='5KNgP'><q id='5KNgP'><span id='5KNgP'><b id='5KNgP'><form id='5KNgP'><ins id='5KNgP'></ins><ul id='5KNgP'></ul><sub id='5KNgP'></sub></form><legend id='5KNgP'></legend><bdo id='5KNgP'><pre id='5KNgP'><center id='5KNgP'></center></pre></bdo></b><th id='5KNgP'></th></span></q></dt></tr></i><div id='5KNgP'><tfoot id='5KNgP'></tfoot><dl id='5KNgP'><fieldset id='5KNgP'></fieldset></dl></div>

          <tbody id='5KNgP'></tbody>

        1. <legend id='5KNgP'><style id='5KNgP'><dir id='5KNgP'><q id='5KNgP'></q></dir></style></legend>

            <bdo id='5KNgP'></bdo><ul id='5KNgP'></ul>

            <small id='5KNgP'></small><noframes id='5KNgP'>

                • 本文介绍了Vaadin 8.5.1- 行更新后刷新网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Vaadin 8.5.1 Grid 来显示 1000 行.一旦通过更改它的属性更新了一行,我使用grid.getDataProvider().refreshItem(selectedRow)或者grid.getDataProvider().refreshAll() 更新行失败.

                  我需要做显式的 grid.setItems() 来查看行的更新属性.

                  我正在使用下面的代码片段来创建一个网格

                   msgGrid = new ABSMsgGrid();列出<ConsoleEntry>messageEntryList = new ArrayList<>();如果(输入控制台!= null){messageEntryList.addAll(inputConsole.getMessageEntryList());}msgGridDataProvider = new ListDataProvider(messageEntryList) {@覆盖公共对象 getId(ConsoleEntry 项) {返回 item.getId();}};msgGrid.setDataProvider(msgGridDataProvider);//在更改网格行的属性时,我使用下面的代码片段私人无效句柄HideRowMenuItem(GridContextMenu contextMenu,ConsoleEntry selectedConsoleItem){if (!selectedConsoleItem.isHidden()) {hideRowMenuItem = contextMenu.addItem("隐藏行", VaadinIcons.EYE_SLASH, selectedMenuItem -> {selectedConsoleItem.hide();**msgGridDataProvider.refreshItem(selectedConsoleItem);**}});}}公共类 ConsoleEntry {@覆盖公共布尔等于(对象 obj){//TODO 自动生成的方法存根if (obj instanceof ConsoleEntry) {ConsoleEntry temp = (ConsoleEntry) obj;字符串 msgRef2 = temp.getMsgRef();返回 this.getMsgRef().equalsIgnoreCase(msgRef2);}返回假;}@覆盖公共 int hashCode() {//TODO 自动生成的方法存根返回 super.hashCode();}公共字符串 getId(){返回 this.getMsgRef();}}

                  我见过类似的问题,但没有一个解决方案有效.

                  更改后如何刷新 vaadin Grid什么?

                  Vaadin - 行修改后刷新网格

                  如果有人可以分享如何解决这个问题的指针

                  TIA

                  解决方案

                  要让一个项目被视为同一个项目,(并且刷新工作)你需要一个正确实现的 equals() 和对象上的 hashCode() 方法.

                  来自文档

                  <块引用>

                  public void refreshItem(T item)

                  从接口复制的描述:DataProvider

                  刷新给定的项目.这种方法应该用于通知所有DataProviderListeners 项目已被更新或替换为新实例.

                  要使其正常工作,该项目必须实现

                  equals( Object) 和 #hashCode() 认为旧项目实例和新项目实例相等,或者

                  DataProvider. getId( Object) 应该被实现以返回一个适当的标识符.

                  除此之外,您应该创建一个 ListDataProvider,将其分配给网格,然后通过先前分配的 ListDataProvider 的同一实例进行更新p>

                  I am using Vaadin 8.5.1 Grid to display 1000's of rows. Once a row is updated with change in it property, I use grid.getDataProvider().refreshItem(selectedRow) or grid.getDataProvider().refreshAll() which fails to update the row.

                  I need to do explicit grid.setItems() to see the updated property of the row.

                  I am using below snippet to create a Grid

                      msgGrid = new ABSMsgGrid();
                  
                      List<ConsoleEntry> messageEntryList = new ArrayList<>();
                      if (inputConsole != null) {
                          messageEntryList.addAll(inputConsole.getMessageEntryList());
                      }
                  
                      msgGridDataProvider = new ListDataProvider<ConsoleEntry>(messageEntryList) {
                  
                          @Override
                          public Object getId(ConsoleEntry item) {
                              return item.getId();
                          }
                      };
                  
                      msgGrid.setDataProvider(msgGridDataProvider);
                  
                  
                  
                  //on changing property of the grid row, i use the below snippet
                  private void handleHideRowMenuItem(GridContextMenu<ConsoleEntry> contextMenu, ConsoleEntry selectedConsoleItem) {
                          if (!selectedConsoleItem.isHidden()) {
                              hideRowMenuItem = contextMenu.addItem("Hide Row", VaadinIcons.EYE_SLASH, selectedMenuItem -> {
                                      selectedConsoleItem.hide();
                                      **msgGridDataProvider.refreshItem(selectedConsoleItem);**
                                  }
                              });
                          }
                  }
                  
                  public class ConsoleEntry {
                  
                          @Override
                          public boolean equals(Object obj) {
                              // TODO Auto-generated method stub
                              if (obj instanceof ConsoleEntry) {
                                  ConsoleEntry temp = (ConsoleEntry) obj;
                                  String msgRef2 = temp.getMsgRef();
                                  return this.getMsgRef().equalsIgnoreCase(msgRef2);
                              }
                              return false;
                          }
                  
                          @Override
                          public int hashCode() {
                              // TODO Auto-generated method stub
                              return super.hashCode();
                          }
                  
                          public String getId(){
                              return this.getMsgRef();
                          }
                  }       
                  

                  I have seen similar question but none of the solutions worked.

                  How to refresh the vaadin Grid after you change something?

                  Vaadin - Refresh grid after row modification

                  Appreciate if any one could share pointers on how to solve this problem

                  TIA

                  解决方案

                  For a item to be seen as the same item, (and the refresh working) you need a corretly implemented equals() and hashCode() methods on the object.

                  From the documentation

                  public void refreshItem(T item)

                  Description copied from interface: DataProvider

                  Refreshes the given item. This method should be used to inform all DataProviderListeners that an item has been updated or replaced with a new instance.

                  For this to work properly, the item must either implement

                  equals(Object) and #hashCode() to consider both the old and the new item instances to be equal, or alternatively

                  DataProvider.getId(Object) should be implemented to return an appropriate identifier.

                  In addition to this, it's you should create a ListDataProvider, assign it to the grid and then do the updated via the same instance of the previously assigned ListDataProvider

                  这篇关于Vaadin 8.5.1- 行更新后刷新网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                  <i id='UJIaV'><tr id='UJIaV'><dt id='UJIaV'><q id='UJIaV'><span id='UJIaV'><b id='UJIaV'><form id='UJIaV'><ins id='UJIaV'></ins><ul id='UJIaV'></ul><sub id='UJIaV'></sub></form><legend id='UJIaV'></legend><bdo id='UJIaV'><pre id='UJIaV'><center id='UJIaV'></center></pre></bdo></b><th id='UJIaV'></th></span></q></dt></tr></i><div id='UJIaV'><tfoot id='UJIaV'></tfoot><dl id='UJIaV'><fieldset id='UJIaV'></fieldset></dl></div>

                      <bdo id='UJIaV'></bdo><ul id='UJIaV'></ul>
                      <legend id='UJIaV'><style id='UJIaV'><dir id='UJIaV'><q id='UJIaV'></q></dir></style></legend>

                      • <tfoot id='UJIaV'></tfoot>
                          <tbody id='UJIaV'></tbody>

                        <small id='UJIaV'></small><noframes id='UJIaV'>