Flex ItemRenderer 问题

发布于 2024-09-05 05:06:03 字数 1172 浏览 5 评论 0原文

我在tilelist中使用Checkbox作为ItemRenderer。我正在尝试设置 复选框通过 xml 选择值。我完美地得到了价值观..但是 复选框无法绑定值(无法接受)。它是 自动为所有复选框设置 true。 这是我的 xml

<PmhTreeAllow>
  <PmhTreeAllowname id='1' label ='Allow Text' isField='false'/>
  <PmhTreeAllowname id='2' label ='Document Link' isField='false'/>
  <PmhTreeAllowname id='3' label ='Test Results Entry'isField='false'/>
  <PmhTreeAllowname id='4' label ='Dummy' isField='false'/>
</PmhTreeAllow>

我的 Tilelist..

<mx:TileList id="tileList" width="160" height="100%" textAlign="left" horizontalScrollPolicy="off" verticalScrollPolicy="off" dataProvider="modelInstance.optionCollList}" columnCount="1" backgroundAlpha="0" borderStyle="none"itemRenderer="com.Frontend.views.treeStructure.myTileList" useRollOver="false" rowHeight="28" itemClick="tileItemClick(event)" columnWidth="150" selectedIndex="0" x="10" y="0">

复选框 ItemRenderer..

<?xml version="1.0" encoding="utf-8"?>
<mx:CheckBox xmlns:mx="http://www.adobe.com/2006/mxml" label="{data.@label}" selected="data.@isField}"/>

提前致谢 阿肖克

Am using Checkbox as ItemRenderer in tilelist. Am trying to setting
checkbox selected values through xml. I got the values perfectly.. but
checkbox could not bind the values(could not accept that). It's
automatically sets true for all checkboxes.
This is my xml

<PmhTreeAllow>
  <PmhTreeAllowname id='1' label ='Allow Text' isField='false'/>
  <PmhTreeAllowname id='2' label ='Document Link' isField='false'/>
  <PmhTreeAllowname id='3' label ='Test Results Entry'isField='false'/>
  <PmhTreeAllowname id='4' label ='Dummy' isField='false'/>
</PmhTreeAllow>

My Tilelist..

<mx:TileList id="tileList" width="160" height="100%" textAlign="left" horizontalScrollPolicy="off" verticalScrollPolicy="off" dataProvider="modelInstance.optionCollList}" columnCount="1" backgroundAlpha="0" borderStyle="none"itemRenderer="com.Frontend.views.treeStructure.myTileList" useRollOver="false" rowHeight="28" itemClick="tileItemClick(event)" columnWidth="150" selectedIndex="0" x="10" y="0">

Check box ItemRenderer..

<?xml version="1.0" encoding="utf-8"?>
<mx:CheckBox xmlns:mx="http://www.adobe.com/2006/mxml" label="{data.@label}" selected="data.@isField}"/>

Thanks in Advance
Ashok

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╭ゆ眷念 2024-09-12 05:06:03

出于性能原因,在 itemRenderer 内部使用绑定被认为是一种不好的做法。相反,监听 FlexEvent.DATA_CHANGE 并手动修改您的值。我打赌这样做会解决你的问题。

尝试这样的 itemRenderer:

<mx:CheckBox xmlns:mx="http://www.adobe.com/2006/mxml" label="{data.@label}" selected="data.@isField}" dataChange="onDataChange()">
<mx:Script><[[
 public function onDataChange():void{
 var dataAsXML = data as XML; 
 this.selected = data.@isField
 this.label = data.@label
]]></mx:Script>
</mx:CheckBox>

我没有对 XML 做很多事情,但我怀疑 XML 属性不会绑定,因为 XML 不像 ActionScript 对象,因此 XML 对象上不存在“propertyChanged”绑定事件它们在 AS3 对象上的方式相同。

For performance reasons, it is considered a bad practice to use binding inside an itemRenderer. Instead listen to the FlexEvent.DATA_CHANGE and manually modify your values. I Bet doing so will solve your issue.

Try an itemRenderer like this:

<mx:CheckBox xmlns:mx="http://www.adobe.com/2006/mxml" label="{data.@label}" selected="data.@isField}" dataChange="onDataChange()">
<mx:Script><[[
 public function onDataChange():void{
 var dataAsXML = data as XML; 
 this.selected = data.@isField
 this.label = data.@label
]]></mx:Script>
</mx:CheckBox>

I don't do a lot with XML, but I suspect that the XML properties will not bind because XML is not like an ActionScript object and therefore the "propertyChanged" Binding events do not exist on the XML object the same way they would be on an AS3 object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文