我找不到一种简单的方法来在Spark DataGrid中删除或隐藏caretIndicator,所以如果没有更好的方法,我会在这里发布解决方案。
答案 0 :(得分:1)
这似乎有效。要隐藏caretIndiator,我们必须基于spark.skins.spark.DataGridSkin创建一个新的数据网格外观。然后在该皮肤中将笔划的alpha或矩形的alpha设置为0.
方法1:
MXML :
<s:DataGrid skinClass="view.skins.AbstractDataGridSkin"/>
AbstractDataGridSkin :
<?xml version="1.0" encoding="utf-8"?>
<spark:DataGridSkin
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
xmlns:spark="spark.skins.spark.*"
xmlns:skins="view.skins.*"
>
<fx:Component id="caretIndicator">
<s:Rect implements="spark.components.gridClasses.IGridVisualElement" alpha="0">
<fx:Script>
<![CDATA[
import spark.components.DataGrid;
import spark.components.Grid;
/**
* @private
*/
public function prepareGridVisualElement(grid:Grid, rowIndex:int, columnIndex:int):void
{
const dataGrid:DataGrid = grid.dataGrid;
if (!dataGrid)
return;
const color:uint = dataGrid.getStyle("caretColor");
caretIndicatorFill.color = color;
}
]]>
</fx:Script>
<s:stroke>
<!--- @private -->
<s:SolidColorStroke id="caretIndicatorFill" color="0x0167FF" weight="0" alpha="0"/>
</s:stroke>
</s:Rect>
</fx:Component>
</spark:DataGridSkin>
方法2:
有another method涉及复制默认的datagrid外观并删除caretIndicator属性。这种方式可能更好:P。
方法3:
这也有效:
<spark:DataGridSkin
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
xmlns:spark="spark.skins.spark.*"
xmlns:skins="view.skins.*"
initialize="caretIndicator = null" />