5 Replies Latest reply on Jan 21, 2008 11:00 PM by Mirza Asim

    Adavnced DataGrid dataproivder in filtered view

    Mirza Asim Level 1
      For example I have 100 records in the dataProvider of Advanced DataGrid, I clicked on item # 20. Now selectedCells[0]["rowIndex"] value will set to 20. Lets I apply filter on data and my selected row become 5th in the datagrid view. Is there any way to get this index 5 programatically? Values in selectedCells array are stored with respect to dataProvider rather records in the dataGrid view
      Regards
        • 1. Re: Adavnced DataGrid dataproivder in filtered view
          sameerb Level 1
          Can you post a sample so that we can have a look at it?
          • 2. Adavnced DataGrid dataproivder in filtered view
            Mirza Asim Level 1
            STEPS:-
            1- Make a file 'SampleForADG.mxml' and then paste the CODE (at bottom of the post) in that file.
            2- Execute the file in debug mode so the trace() result can be printed on console
            2- After executing the file you will see two controls (AdvancedDataGrid, Button). Select any cell in the last row that is:
            __________20__________J__________KSA__________Male__________E
            3- As there are five records so the selected index with respect to view is 4 that i can access from selectedCells[0]["index"]. Though selectedCells array is contains the indicies with respect to dataProvider but in this case view's and dataProvider's indicies are same.
            4- Now Click the Apply Filter button. ( This filter, basically, shows the records with age greater or equal to 20 ). Only two records will remain for view others will be filtered out.
            5. Now the selected Index with respect to view is 1 but when I access selectedCells[0]["index"], it contains 4. So, in this senario selectedCells array is not helpful for me because I need index with respect to view (i.e. 1). Is there any way to get this index?

            ------------------------------------------CODE-------------------------------------------- -----------
            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="doIt()">

            <mx:Script>
            <![CDATA[
            import mx.collections.ArrayCollection;

            [Bindable]
            private var initDG:ArrayCollection = new ArrayCollection([
            {Name: "A", Age: 26, Gender: "Male", Country: "Pakistan", City: "I"},
            {Name: "B", Age: 2, Gender: "Male", Country: "Pakistan", City: "M"},
            {Name: "C", Age: 1, Gender: "Female", Country: "Pakistan", City: "M"},
            {Name: "D", Age: 3, Gender: "Male", Country: "KSA", City: "J"},
            {Name: "E", Age: 20, Gender: "Male", Country: "KSA", City: "J"}
            ]);

            public function doIt():void
            {
            initDG.filterFunction= processFilter;
            }

            private function processFilter(item:Object):Boolean
            {
            return item["Age"] >= 20;
            }

            private function onClick():void
            {
            initDG.refresh();
            trace(myADG.selectedCells[0]["rowIndex"]);
            }
            ]]>
            </mx:Script>

            <mx:AdvancedDataGrid id="myADG" dataProvider="{initDG}" selectionMode="singleCell"/>
            <mx:Button label="Apply Filter" id="btnFilter" click="onClick()" y="200"/>
            </mx:Application>

            ------------------------------------------------------------------------------------------ ----------------
            • 3. Re: Adavnced DataGrid dataproivder in filtered view
              sameerb Level 1
              The selectedCells property is not getting updated when the filter function is applied.
              Click and select the cell again after applying the filter function and click the button to see the desired output.

              Can you log this issue in the public bug base - https://bugs.adobe.com/flex/

              • 4. Re: Adavnced DataGrid dataproivder in filtered view
                Mirza Asim Level 1
                Thanks Sameer!
                I was not sure whether this is a bug or not? Thats why I posted this question to confirm whether this is a bug or I am unable to find the solution for my problem. But now a more confident that this a bug and I have reported it as well
                Regards
                • 5. Re: Adavnced DataGrid dataproivder in filtered view
                  Mirza Asim Level 1
                  Does anyone of you have any alternative to avoid this bug. I am stuck and can't continue my application further just because of this bug.