在数据网格中滚动时,选择会发生变化(Selection shifts while scrolling in data grid)

编程入门 行业动态 更新时间:2024-10-15 00:25:23
在数据网格中滚动时,选择会发生变化(Selection shifts while scrolling in data grid)

我也是flex和这个论坛的新手。 我有一个datagrid,它在itemrenderer中显示mx:VBox中的图像,现在我需要允许用户多选VBox。 但是当我选择一些项目时,更改VBox的背景颜色并滚动网格,它会自动选择一些重新项目并设置相同的背景颜色。 我知道flex重用项目渲染器,我在这里读到它

但是如何阻止我只选择项目。 下面是我的代码

<mx:DataGrid id="dgPhoto" variableRowHeight="true" dataProvider="{StyleItemsArray}" verticalGridLineColor="white" verticalGridLines="true" showHeaders="false" width="100%" height="100%" allowMultipleSelection="true" > <mx:columns> <mx:DataGridColumn width="250" headerText="Preview" dataField="img"> <mx:itemRenderer> <mx:Component> <mx:VBox height="215" horizontalAlign="center" click="this.setStyle('backgroundColor', 'white')"> <mx:Script> <![CDATA[ ]]> </mx:Script> <mx:HBox horizontalAlign="center" horizontalGap="0"> <mx:Image brokenImageBorderSkin="{null}" brokenImageSkin="@Embed(source='../img/errorIcon231.png')" id="image1" width="180" source="{data.source}" horizontalAlign="right"></mx:Image> <mx:VBox horizontalAlign="center" verticalGap="2"> <mx:Button click="{btnZoom_clickHandler(event, data.sourceHRES, data.label, data.IDMSFile)}" toolTip="Zoom" id="btnZoom" icon="@Embed(source='../img/zoom.png')" fillColors="#BB3030"/> <mx:Button click="{btnDownload_clickHandler(event, data.IDMSFile)}" toolTip="Place this style" id="btnDownload" icon="@Embed(source='../img/Download.png')" fillColors="#BB3030"/> </mx:VBox> </mx:HBox> </mx:VBox> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid>

I'm newbie to flex and this forum as well. I've a datagrid which displayed images in mx:VBox in itemrenderer, now I need to allow user to multi select the VBox . but when I select some item(s), change the background color of VBox and scroll the grid it automatically select some rendom item(s) and set the same background color. I know flex reuse item renderer, which I read it here

but how can I prevent my selection only item(s). below is my code

<mx:DataGrid id="dgPhoto" variableRowHeight="true" dataProvider="{StyleItemsArray}" verticalGridLineColor="white" verticalGridLines="true" showHeaders="false" width="100%" height="100%" allowMultipleSelection="true" > <mx:columns> <mx:DataGridColumn width="250" headerText="Preview" dataField="img"> <mx:itemRenderer> <mx:Component> <mx:VBox height="215" horizontalAlign="center" click="this.setStyle('backgroundColor', 'white')"> <mx:Script> <![CDATA[ ]]> </mx:Script> <mx:HBox horizontalAlign="center" horizontalGap="0"> <mx:Image brokenImageBorderSkin="{null}" brokenImageSkin="@Embed(source='../img/errorIcon231.png')" id="image1" width="180" source="{data.source}" horizontalAlign="right"></mx:Image> <mx:VBox horizontalAlign="center" verticalGap="2"> <mx:Button click="{btnZoom_clickHandler(event, data.sourceHRES, data.label, data.IDMSFile)}" toolTip="Zoom" id="btnZoom" icon="@Embed(source='../img/zoom.png')" fillColors="#BB3030"/> <mx:Button click="{btnDownload_clickHandler(event, data.IDMSFile)}" toolTip="Place this style" id="btnDownload" icon="@Embed(source='../img/Download.png')" fillColors="#BB3030"/> </mx:VBox> </mx:HBox> </mx:VBox> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid>

最满意答案

您应在'data'项中存储和处理您选择/未选择的状态,该项将传递给每个itemrenderer。

或者您可以从itemrenderer引用网格并检查当前数据是否在所选项目中。

或者,您可以扩展标准网格项目渲染器,而不是使用Box和覆盖方法,这些方法在选择/取消选择项目时调用。

但有没有特别需要使用旧的,有缺陷的,刚性的mx数据网格而不是火花的? 您真的需要自定义选择指示而不是样式标准选择颜色吗?

You shall store and handle your selected/unselected status in 'data' item which is passed to each itemrenderer.

Or you can reference grid from itemrenderer and check if current data is among selected items.

Or you can extend standard grid itemrenderer instead of using Box and override methods which are called when item is selected/unselected.

But is there any particular need for usage of that old, buggy, rigid mx datagrid instead of spark one? Do you really need custom selection indication instead of styling standard selection colors?

更多推荐

本文发布于:2023-08-06 20:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1455804.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   发生   数据   Selection   grid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!