2010-11-02 24 views
2

如果您按下ADG上的鍵盤按鍵,則所選行將移至第一行,從而找到第一列單元格的文本以您剛按下的字符開頭。有誰知道是否有財產將此行爲關閉?按AdvancedDataGrid上的鍵選擇行:如何禁用?

這裏有一個簡單的代碼片段,顯示這一點,如果你想使用一些代碼來打......

THX

˚F


<?xml version="1.0"?> 
<!-- dpcontrols/adg/SimpleADG.mxml --> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:mx="library://ns.adobe.com/flex/mx" 
     xmlns:s="library://ns.adobe.com/flex/spark"> 

<fx:Declarations> 
    <s:ArrayCollection id="myCbDb"/> 
</fx:Declarations> 

<fx:Script> 
    <![CDATA[ 
    import mx.collections.ArrayCollection; 
    import mx.events.AdvancedDataGridEvent; 
    import mx.events.FlexEvent; 
    import mx.events.ListEvent; 


    [Bindable] 
    private var dpADG:ArrayCollection = new ArrayCollection([ 
    {Row:1, Name:'Pavement', cost:10, length:0.1}, 
    {Row:2, Name:'Pavement', cost:20, length:.2}, 
    {Row:3, Name:'Saner', cost:30, length:.30}, 
    {Row:4, Name:'Saner', cost:10, length:.40}, 
    {Row:5, Name:'The Doors', cost:5, length:.50}, 
    {Row:6, Name:'The Doors', cost:0, length:.60}, 
    {Row:7, Name:'Grateful Dead', cost:20, length:.70}, 
    {Row:8, Name:'Grateful Dead', cost:10, length:.80}, 
    {Row:9, Name:'Grateful Dead', cost:10, length:.90}, 
    {Row:10, Name:'The Doors', cost:5, length:1}, 
    {Row:11, Name:'The Doors', cost:10, length:0}, 
    {Row:12, Name:'The Doors', cost:10, length:0}, 
    {Row:13, Name:'The Doors', cost:10, length:0}, 
    {Row:14, Name:'The Doors', cost:10, length:0}, 
    {Row:15, Name:'The Doors', cost:10, length:0}, 
    {Row:16, Name:'The Doors', cost:10, length:0}, 
    {Row:17, Name:'The Doors', cost:10, length:0}, 
    {Row:18, Name:'The Doors', cost:10, length:0}, 
    {Row:19, Name:'The Doors', cost:10, length:0}, 
    {Row:20, Name:'The Doors', cost:10, length:0}, 
    {Row:21, Name:'The Doors', cost:10, length:0}, 
    ]);     


    ]]> 
</fx:Script> 

<mx:AdvancedDataGrid 
    id="adg" 
    width="100%" height="100%" 
    selectionMode="multipleRows" 
    dataProvider="{dpADG}"> 
    <mx:columns> 
    <mx:AdvancedDataGridColumn dataField="Name" /> 
    <mx:AdvancedDataGridColumn dataField="cost" editorDataField="value"/> 
    <mx:AdvancedDataGridColumn dataField="length" editorDataField="value"/> 
    </mx:columns> 
</mx:AdvancedDataGrid>   
</s:Application> 
+0

好吧,我通過在第一列中的每個字符串前添加空格(調整與該列關聯的LabelFunction函數)來破解解決方案 - 非常可怕,但它似乎有訣竅。如果有一種明顯的方法可以解決這種行爲,我們仍然會很樂意聽到。 – 2010-11-02 18:48:47

+0

感謝您提供完整的示例。這對於尋找解決方案總是非常有幫助的。我在下面張貼了我的。 – 2010-11-03 08:32:59

回答

2

爲了禁用此行爲,您必須使用擴展AdvancedDataGrid的自定義組件。在此組件中,您可以覆蓋方法findKey(),該方法負責選擇以按鍵開頭的第一行。

public class CustomAdvancedDataGrid extends AdvancedDataGrid 
{ 
    public function CustomAdvancedDataGrid() 
    { 
     super(); 
    } 

    protected override function findKey(eventCode:int):Boolean 
    { 
     return false; 
    } 
} 
+0

這個技巧!謝謝格哈德! – 2010-11-04 15:39:06