flex advanceDatagrid 与单选按钮问题
我正在使用 Flex 3 的高级 DataGrid 和分层数据 我还在另一列中添加了图块列表作为项目渲染器 在该图块列表中,我添加了单选按钮作为项目渲染器 如果我更改单选按钮的值,层次树就会展开 如果滚动条出现,则单选按钮的值正在改变
<mx:AdvancedDataGrid contextMenu="{cm}" backgroundAlpha="0" styleName="TreeUser" dataProvider="{modelInstance._treeUserXml}"
id="treeAdg" width="100%" height="100%" showHeaders="false" doubleClick="treeDoubleClick(event)" doubleClickEnabled="true"
displayItemsExpanded="false" click="onItemClick(event)" borderStyle="none" rowHeight="25">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="name"/>
<mx:AdvancedDataGridColumn id="treeItem" itemRenderer="com.Frontend.views.TreeUser.TreeStructureTileList"/>
</mx:columns>
这是高级数据网格,添加分层数据作为数据提供程序
<containers:TileListEx id="tileList" width="100%" height="100%" textAlign="left"
horizontalScrollPolicy="off" verticalScrollPolicy="off" direction="horizontal"
dataProvider="{data.driver}" itemClick="tileItemClick(event)"
backgroundAlpha="0" borderStyle="none" paddingLeft="0" paddingTop="0"
useRollOver="false" rowHeight="25" itemRenderer="com.Frontend.views.TreeUser.tieListRenderer">
</containers:TileListEx>
,这是我添加 data.driver 作为 dataprovider
如果我单击单选按钮,其值会发生变化,但如果滚动,该值将随机变化,因为 itemrenderer 帮助我解决了这个问题
I am using Advanced DataGrid of Flex 3 with hierarchical data
and also i added tile list as a item renderer in another column
in that tile list i added radiobutton as item renderer
if i change the radio selected value the hierarchical tree sould expand
if the scroll bar will come the radio button value is changing
<mx:AdvancedDataGrid contextMenu="{cm}" backgroundAlpha="0" styleName="TreeUser" dataProvider="{modelInstance._treeUserXml}"
id="treeAdg" width="100%" height="100%" showHeaders="false" doubleClick="treeDoubleClick(event)" doubleClickEnabled="true"
displayItemsExpanded="false" click="onItemClick(event)" borderStyle="none" rowHeight="25">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="name"/>
<mx:AdvancedDataGridColumn id="treeItem" itemRenderer="com.Frontend.views.TreeUser.TreeStructureTileList"/>
</mx:columns>
this is advanced data grid adding hierarchical data as a data provider
<containers:TileListEx id="tileList" width="100%" height="100%" textAlign="left"
horizontalScrollPolicy="off" verticalScrollPolicy="off" direction="horizontal"
dataProvider="{data.driver}" itemClick="tileItemClick(event)"
backgroundAlpha="0" borderStyle="none" paddingLeft="0" paddingTop="0"
useRollOver="false" rowHeight="25" itemRenderer="com.Frontend.views.TreeUser.tieListRenderer">
</containers:TileListEx>
and this is the tile list where i added data.driver as a dataprovider<mx:RadioButton id="radio" label="{data.name}" click="checkClick(event)" width="100%"/>
if i click the radio button value its changing but if scroll will come the value will changing randomly because of itemrenderer help me to resolve this problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您面临的问题很简单,作为 itemRenderer 实例创建的组件可以在 TileList 中重用。因此,如果您单击作为列表第一项的 itemRenderer 的 RadioButton,然后向下滚动,则单击的 RadioButton(由于滚动而消失)将用作出现的其中一个项目的 itemRenderer。您要做的就是使您的 itemRenderer 以某种方式依赖于“data”属性,例如向其添加“selected”属性,并在 data.selected==true 时将 RadioButton 显示为选中状态。您还需要在 RadioButton 单击处理程序中将 selected 设置为适当的值。
The problem you're facing is simply that the components created as instances of itemRenderer are reusable across your TileList. So if let's say you click RadioButton that is itemRenderer of first item of the List and then you scroll down, the clicked RadioButton (that dissapeared due to scrolling) will be used as itemRenderer of one of the items that appeared. What you have to do is make your itemRenderer somehow dependent on 'data' property, like adding 'selected' property to it for example and displaying RadioButton as checked if data.selected==true. You also need to set selected to appropriate value in your RadioButton click handler.