Flex - 将数据传递到选项卡式视图中
我有一个有 4 个视图的项目,我将 tabBar 与 viewStack/NavigatorContent 一起使用。我设置了几个 HTTPServices 来收集 XML 并转换为可绑定的 ArrayCollections。何时以及如何将数据传递到图表、数据网格等只有用户单击选项卡才能看到的内容的最佳方式?现在我已经为每个项目设置了 createComplete 函数,然后传递它。虽然它似乎有效,但这是最好的方法,还是有更好、甚至更快的方法?
谢谢, 标记
I have a project that has 4 views where I'm using the tabBar with viewStack/NavigatorContent. I have a couple HTTPServices set up gathering the XML and converting to Bindable ArrayCollections. When and how is the best way to pass that data to such things as charts, dataGrids, etc. that aren't seen until the user clicks a tab? Right now I have each item set up with creationComplete functions that pass it then. Although it seems to be working, is this the best way, or is there something better and maybe even quicker?
Thanks,
Mark
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好的方法是使用数据绑定。假设您有一个主容器,其中包含代表选项卡内容的 ViewStack 组件。因此,您应该在主容器中为数据设置
[Bindable]
属性,如下所示:等等。
因此,对于包含图表的组件,您应该使用数据绑定填充图表数据:
当然,您应该引入
MyChartsTab
组件中的相同chartData
字段(确保它是public
)。您的图表也可以填充数据绑定。因此,在获取数据后,您只需填写主组件中的字段,数据绑定将执行其余工作,而无需关心您这边的初始化。
The best way is using data binding. Say you have a main container which contains
ViewStack
witch components representing tabs content. So you should have[Bindable]
properties for data in a main container like the following:etc.
So for the component, containing chart, you should populate chart data with data binding:
And of course you should introduce the same
chartData
field (make sure it ispublic
) in yourMyChartsTab
component. Your charts there can be populated with data binding too.So after getting data you just fill your fields in main component and data binding performs the rest job without any care of initialization from your side.
创建视图时,请确保允许使用公共变量(例如“dataProvider”),您可以在其中绑定所需的数据。像这样:
在自定义组件中,您将拥有:
When creating your views, make sure you allow a public variable (like 'dataProvider') where you can bind the data it needs. Like this:
And within the custom component you'd have: