3 Replies Latest reply on Jul 2, 2010 10:16 AM by Flex harUI

    Data binding to datagrid.selectedIndex after filtering

    Yury Bel

      Hi!

      The problem is that I can't correctly get selectedIndex of the datagrid using the data binding technique.

      Well, my source:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
          <mx:Script>
              import mx.collections.ArrayCollection;
         
              [Bindable]
              private var myAC:ArrayCollection = new ArrayCollection([{n:"abc"}, {n:"cde"}]);
             
              private function filter():void {
                  myAC.filterFunction = function(i:Object):Boolean {return false;}
                  myAC.refresh();
              }
          </mx:Script>
         
          <mx:DataGrid id="myDG" dataProvider="{myAC}" />
          <mx:Label text="Selected index is: {myDG.selectedIndex}"  />
          <mx:Button label="Button1" click="filter()"/>
      </mx:Application>

       

      If I select a row and then click the Button1 - I see that there is nothing in the grid but the label text is: "Selected index is: 1".

       

      Any ideas?

       

      Thanks