5 Replies Latest reply on Feb 22, 2012 1:42 AM by Sathyamoorthi

    mx datagrid problem.


      Hi all,


           I am using flex 4.6's mx.datagrid. i applied some filter function to my datagrid. it works very good and fast. But when i sort the column and reapply my filter function, it doesn't work



      Any ideas?

        • 1. Re: mx datagrid problem.
          Sathyamoorthi Level 2

          i didn't find solution yet. anyone faced this problem before?

          • 2. Re: mx datagrid problem.
            Flex harUI Adobe Employee

            What happens instead?  What code are you using to sort and filter?

            • 3. Re: mx datagrid problem.
              Sathyamoorthi Level 2

              Feel happy by your presence.


              I have my own filterfunction to filter my data. But for sorting i used datagrid's default sort functionality (click on column header to sort data).


              When i click on column header to sort and reapply my custom filter function on the dataprovider, Datagrid behaves in different way. I think there is a confusion between filterfunction and sorting.


              should i not use datagrid's sort functionlity while i have my own filter function?

              • 4. Re: mx datagrid problem.
                Flex harUI Adobe Employee

                I’m pretty sure they both can work together.  If you provide more detail and/or show the actual code, it easier for people to help.

                • 5. Re: mx datagrid problem.
                  Sathyamoorthi Level 2



                       Thanks Alex.


                       I resolved this problem. I loop throw dataprovider and update some properties of dataprovider before apply filterfunction. It works good when sort is not applied.

                  while sorting is applied, and do the dataprovider updation, datagird dispatch 'collectionchange' event and apply sorting.


                       For example when i update the property of 0th row, datagrid sorts the dataprovider. now 0th goes to 20th row 20 comes to the 0th index.

                  Now i increment index to 1. But actually i missed 20th row which is now in 0th index.


                       So i didn't get my expected result while filter my data. I resolved this problem by the following way.



                      var ISortTemp:ISort; = this.dataProvider.sort;

                      this.dataProvider.sort = null;



                  for (var index:int = 0; index < dataProvider.length; index ++)


                                                                                             dataProvider[index][dgdColumn.dataField].@sel = "0";



                    this.dataProvider.sort = ISortTemp;

                                                          this.dataProvider.filterFunction = FltDataProvider;