如何用来自后端的数据填充CellTree [英] How to populate a CellTree with data from the back end

查看:139
本文介绍了如何用来自后端的数据填充CellTree的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CellTree有一个构造函数,它需要一个TreeModel。我不能通过setter设置树模型。



我通过异步rpc调用获取树的数据,创建相应的演示者时触发此调用到保存树的视图,但这意味着也创建了视图,没有填充必要数据的树模型。



当数据返回时,我设置根节点,但该模型已经创建,没有根,所以它没有得到更新...



我走了这条路,因为我想要以更好地控制树节点的渲染。



两种可能的解决方案...


  1. 保持视图的呈现,直到抓取返回,这样当创建树时模型包含所有信息 - 我该如何做到这一点?


  2. 一旦数据返回,并在模型上设置,告诉树更新...我该如何做?

  3. >

    解决方案


    1. 当您构建视图时,您必须将 CellTree 设置为
      ListDataProvider

    2. 当你得到你的数据抛出RPC调用你只更新ListDataProvider,你的CellTree将被更新并自动呈现。
    3. 开发人员指南中提供动态数据 href =http://code.google.com/intl/ru-RU/webtoolkit/doc/latest/DevGuideUiCellWidgets.html#data-provider =nofollow> - 细胞小工具。继承人快速报价:


      ListDataProvider将您的单元小部件绑定到java.util.List。对内部列表的任何更改(可通过getList()访问)都将反映在视图中。视图在当前事件块结束时更新,因此您可以进行多个同步更改而不会导致多次刷新视图。



      The CellTree has a constructor that takes a TreeModel. I can't set the tree model via a setter.

      I fetch the data for the tree via an asynchronous rpc call, this call is triggered on creation of the presenter corresponding to the view that holds the tree, but that means the view is also created, without the tree model populated with the necessary data.

      When the data does return I set the root node on the model, but the model is already created without a root so it doesn't get the update...

      I've gone this route because I want to have better control over the rendering of the tree nodes.

      Two possible solutions...

      1. Hold the render of the view until the fetch has come back so that when the tree is created the model has all the information - How do I do this?

      2. Once the data comes back, and is set on the model, tell the tree to update... How do I do this?

      解决方案

      1. When you build a view you must setup your CellTree over ListDataProvider.
      2. When you get your data throw RPC call you only update ListDataProvider, your CellTree will be updated and re rendered automatically.

      Please read Providing Dynamic Data of Developer's Guide - Cell Widgets. Heres quick quote:

      ListDataProvider binds your cell widget to a java.util.List. Any changes to the internal list, which can be accessed via getList(), will be reflected in the views. The views are updated at the end of the current event block, so you can make multiple synchronous changes without causing multiple refreshes of the views.

      这篇关于如何用来自后端的数据填充CellTree的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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