flex:当我将鼠标悬停在包含可换肤容器的数据网格中时出现边框
我有一个项目,在其中显示数组中的内容。我还需要显示评级 - 介于 1 到 5 颗星之间,
每行都有正确的交替阴影,效果很好 - 但是,当我将鼠标悬停在 itemrenderer 中的可换肤计数器(名为 cont)仍然保留该行的原始颜色。当我们使用 fxg 图形时,我们有一个可换肤的容器框,其中包含具有一种色调的评级,它位于较大的表格内 - 鼠标悬停时行颜色发生变化。附加屏幕截图 - 您可以看到评级框(深灰色)和鼠标悬停时突出显示的行之间的蓝色细线...
我被告知从数据网格转移到列表以解决此问题并获得更好的性能 - 似乎是一项艰巨的任务我搞砸了。作为一个更简单的选择,正在寻找 我愿意任一 a)使可换肤容器颜色消失,因此我在鼠标悬停时看到一行中的单一颜色 b)禁用鼠标悬停时网格行的颜色更改,因此可以避免此问题
弄乱之前的条目 - 因此重述问题...
谢谢
数据网格非常简单,如下所示
<mx:DataGrid id="experimentgrid" fontSize="{12}" fontWeight="bold" color="#006837" styleName="dataGridStyle" rowHeight="{15}" borderVisible="false" showHeaders="false" x="{20}" y="{50}" width="{900}" height="{350}" dataProvider="{arr_expList}" itemClick="onItemExp(event);" creationComplete="setColWidths()" verticalScrollPolicy="auto" verticalScrollBarStyleName="scrollStyle" >
<mx:columns>
<mx:DataGridColumn id="col11" dataField="no" resizable="true" />
<mx:DataGridColumn id="col12" dataField="Name" resizable="true" />
<mx:DataGridColumn id="col13" dataField="Rating" itemRenderer="itemRenderers.experimentGriditemRender" resizable="true"/>
</mx:columns>
项目渲染器代码如下
<?xml version="1.0" encoding="utf-8"?>
<s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
focusEnabled="true">
<fx:Script>
<![CDATA[
import assets.graphics.dotrating;
import mx.controls.dataGridClasses.*;
import mx.events.FlexEvent;
import spark.core.SpriteVisualElement;
private var mydot:SpriteVisualElement;
override public function set data(value:Object):void
{
if(value != null)
{
cont.removeAllElements();
for(var i:int=0;i<value.Rating;i++)
{
mydot = new dotrating();
//600 is a stand-in for some calculations
mydot.x= (600*0.02)+(i*600*0.02);
mydot.y= (600*0.012);
//mydot.x = (i*600*0.02);
mydot.height = 600*0.013;
mydot.width = 600*0.013;
cont.addElement(mydot);
}
}
}
]]>
</fx:Script>
<s:SkinnableContainer id = "cont" top="0" left="0" right="0" bottom="0" height="{600*0.02}">
</s:SkinnableContainer>
</s:MXDataGridItemRenderer>![enter image description here][2]
I have a project where I display content from an array. I also need to display ratings- which is between 1- 5 stars
works fine with correct alternate shading for each line- however, when I mouse-over, the skinnable countainer in the itemrenderer(named cont) still retains the original color it had for that row. As we are using fxg graphics, we have a a skinnable container box containing the ratings with one shade, that lies just within the larger table - with row color having changed on mouse-over. Screenshot attached- you can see the thin patch of blue between the ratings box(dark grey) and the highlighed row on mouseover...
I was told to shift from Datagrid to List to resolve this and for better performance- seems like a biggish task which I messed up. As an easier alternative, was looking to
I would like to either
a) get the skinnable container color to disappear, so I see single color in a row on mouseover
b) disable the color change on mouseover for the grid rows, so this issue is avoided
messed up previous entry- hence restating issue...
Thanks
The datagrid is very straighforward as below
<mx:DataGrid id="experimentgrid" fontSize="{12}" fontWeight="bold" color="#006837" styleName="dataGridStyle" rowHeight="{15}" borderVisible="false" showHeaders="false" x="{20}" y="{50}" width="{900}" height="{350}" dataProvider="{arr_expList}" itemClick="onItemExp(event);" creationComplete="setColWidths()" verticalScrollPolicy="auto" verticalScrollBarStyleName="scrollStyle" >
<mx:columns>
<mx:DataGridColumn id="col11" dataField="no" resizable="true" />
<mx:DataGridColumn id="col12" dataField="Name" resizable="true" />
<mx:DataGridColumn id="col13" dataField="Rating" itemRenderer="itemRenderers.experimentGriditemRender" resizable="true"/>
</mx:columns>
The item renderer code is as follows
<?xml version="1.0" encoding="utf-8"?>
<s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
focusEnabled="true">
<fx:Script>
<![CDATA[
import assets.graphics.dotrating;
import mx.controls.dataGridClasses.*;
import mx.events.FlexEvent;
import spark.core.SpriteVisualElement;
private var mydot:SpriteVisualElement;
override public function set data(value:Object):void
{
if(value != null)
{
cont.removeAllElements();
for(var i:int=0;i<value.Rating;i++)
{
mydot = new dotrating();
//600 is a stand-in for some calculations
mydot.x= (600*0.02)+(i*600*0.02);
mydot.y= (600*0.012);
//mydot.x = (i*600*0.02);
mydot.height = 600*0.013;
mydot.width = 600*0.013;
cont.addElement(mydot);
}
}
}
]]>
</fx:Script>
<s:SkinnableContainer id = "cont" top="0" left="0" right="0" bottom="0" height="{600*0.02}">
</s:SkinnableContainer>
</s:MXDataGridItemRenderer>![enter image description here][2]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我很确定您想要设置 autoDrawBackground 属性设置为 false。默认情况下是这样。
除此之外,您可以尝试使用 DataGrid 的 rollOverColor 样式。
I'm pretty sure you want to set the autoDrawBackground property of the itemRenderer to false. It s true by default.
Beyond that, you can try experimenting with the rollOverColor style of the DataGrid.
是的,我肯定会使用带有自定义项目渲染器的列表而不是数据网格。数据网格很重,并且有很多您甚至没有使用的额外功能。这也能解决你的问题。
Yeah, I would definitely use a list with a custom item renderer instead of a datagrid. Datagrids are heavy and have a lot of extra functionality that you aren't even using. This would also solve your issue.