4 Replies Latest reply on May 13, 2011 5:28 AM by jfb00

    ArrayCollection error

    jfb00 Level 3

      Hi All,

      I am getting this error when i try to add an item to an arrayCollection:

      Error: Find criteria must contain at least one sort field value.

      at mx.collections::Sort/findItem()
      at mx.collections::ListCollectionView/getItemIndex()

       

      I have an advanced datagrid, base on a comboBox change I reload the data to the dataprovider so I have to remove all the items from the arraycollection and add the new data to be display in my ADG.

      I was removing the items with removeAll, the error was showing at this line so change my code to using:

      myArrayCollection = null;

      myArrayCollection = new ArrayCollection();

       

      After adding the new items to the array collection using a loop I have a sort:

      ----Loop----
      tempObject = new Object();
      
      myArrayCollection.addItem(tempObject);
      myArrayCollection.refresh();
      ----End Loop----
      
      
      var sort:Sort = new Sort();
      my_adg.validateNow();
      sort.fields = [new SortField("MY_FIELD",true)];
      my_adg.dataProvider.sort = sort;
      my_adg.dataProvider.refresh();
      

       

      If I remove this sort, all work.

      What is the issue here? The null is not removing the sort?

      Also, in my ADG I have grouping collection.

      <mx:GroupingCollection id="myGroupedData" source="{myArrayCollection}" >

      Any ideas?

      Thanks

       

      Johnny