2

If you press a keyboard key on an ADG the selected row moves to the first line it finds whose first column cell's text starts with the character you just pressed. Does anyone know if there's a property to turn that behavior off?

Here's a simple code snippet that shows this, in case you'd like to play with some code...

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>
2
  • OK, I hacked a solution by adding spaces in front of each string in the first column (tweaking the LabelFunction function associated with the column) - pretty horrible but it seems to do the trick. Would still love to hear if there's an obvious way to turn that behavior off. Nov 2, 2010 at 18:48
  • Thanks for providing a complete example. That's always quite helpful in finding a solution. I've posted mine below. Nov 3, 2010 at 8:32

1 Answer 1

2

In order to disable this behaviour you have to use a custom component that extends AdvancedDataGrid. Within this component you can override the method findKey() which is responsible for selecting the first row that starts with the pressed key.

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.