Flex 中 ItemRenderer 中组件 Spark 中的数据
我需要使用从另一个视图接收的数据创建幻灯片。
我这样调用幻灯片视图:
<s:List id = "list" dataProvider = "{actions}"
change = "navigator.pushView (DetailsProduct, list.selectedItem) ">
<s:itemRenderer>
<fx:Component>
<s:MobileIconItemRenderer
labelField = "title"
messageField = "description"
decoratorClass = "{data.icon}">
</s:MobileIconItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
我认为问题是发送参数的时间,因为我正在传递所选项目并且必须传递整个列表。
另一个问题是在视图中,我可以看到列表外部收到的对象,但看不到列表内部的对象。
使用此代码,对象出现,但后退和前进按钮不起作用。
<s:List id = "myList"
dataProvider = "{actions}">
</s:List>
<s:Image source="{data.icon}"/>
<s:Label text="{data.title}"/>
<s:Label text="{data.description}"/>
<s:HGroup>
<s:Button label="Forward" click="imgForward(event)"/>
<s:Button label="Back" click="imgBack(event)"/>
</s:hgroup>
这段代码没有显示任何内容,甚至以相同的方式调用对象。
<s:List id = "myList"
dataProvider = "{actions}">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<s:Image source="{data.icon}"/>
<s:Label text="{data.title}"/>
<s:Label text="{data.description}"/>
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
<s:HGroup>
<s:Button label="Forward" click="imgForward(event)"/>
<s:Button label="Back" click="imgBack(event)"/>
</s:hgroup>
I need to create a slideshow using data received from another view.
I'm calling the slideshow's view like this:
<s:List id = "list" dataProvider = "{actions}"
change = "navigator.pushView (DetailsProduct, list.selectedItem) ">
<s:itemRenderer>
<fx:Component>
<s:MobileIconItemRenderer
labelField = "title"
messageField = "description"
decoratorClass = "{data.icon}">
</s:MobileIconItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
I think the problem is the time to send the parameter because I'm passing the selected item and must pass the entire list.
And the other problem is in the view, I can see the object received outside the list but not inside it.
With this code the object appears, but the back and forward buttons doesn't work.
<s:List id = "myList"
dataProvider = "{actions}">
</s:List>
<s:Image source="{data.icon}"/>
<s:Label text="{data.title}"/>
<s:Label text="{data.description}"/>
<s:HGroup>
<s:Button label="Forward" click="imgForward(event)"/>
<s:Button label="Back" click="imgBack(event)"/>
</s:hgroup>
And this code shows nothing, even the object being called the same way.
<s:List id = "myList"
dataProvider = "{actions}">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<s:Image source="{data.icon}"/>
<s:Label text="{data.title}"/>
<s:Label text="{data.description}"/>
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
<s:HGroup>
<s:Button label="Forward" click="imgForward(event)"/>
<s:Button label="Back" click="imgBack(event)"/>
</s:hgroup>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我实际上不明白你想要完成什么。定义了 data 属性在 IDataRenderer 界面。
当组件用作渲染器时,组件实例表示的数据元素将使用 data 属性传递到渲染器中。
您没有量化“有效或无效”的含义,所以我不确定您想要的行为是什么,也不确定为什么一个是错误的,而一个不是。在您的第一个样本中,我不期望有数据属性具有任何值:
我不确定 dataProvider 包含什么,但如果它包含对象,我希望列表中显示一些内容,并且标签不显示任何视觉元素,因为如果您想引用 data 属性,则很可能为 null。在列表中选择的项目,您可以访问如下内容,而不是访问数据:
它使用列表实例中的 selectedItem 属性来修改显示元素
在您创建 itemRenderer 的第二个示例中,我希望它能够。 work:
但是,itemRenderer 不执行任何操作来定位图像或两个标签,因此我希望它们彼此分层,这可能不是理想的行为,您可以设置 X 和 Y 值来调整它们的大小
。你想详细说明具体问题;为什么你的第一个样本“有效”而第二个样本不起作用,请这样做。
I actually don't understand what you're trying to accomplish. The data property is defined in the IDataRenderer interface.
When a component is used as a renderer, the data element that the instance of component represents is passed into the renderer using the data property.
You didn't quantify what "works or "not works" mean, so I'm not sure what your desired behavior is, nor why one is wrong, and one isn't. In your first sample, I would not expect a data property to have any value:
I'm not sure what the dataProvider contains, but if it contains objects, I would expect something to be displayed in the list. I would expect the Image, and the labels to display no visual elements, because the data property is most likely null. If you wanted to reference the item selected in the list, instead of accessing data, you could access something like this:
It uses the selectedItem property from the list instance to modify the display elements.
In your second sample, where you do create an itemRenderer, I would expect it to work:
However, the itemRenderer does nothing to position the image or two labels, so I would expect them to be layered on top of each other, which is probably not desirable behavior. You can set the X and Y values to size them.
If you want to elaborate on the specific problems; why your first sample 'works' and the second doesn't, please do.