1 Reply Latest reply on Mar 20, 2013 9:01 AM by DeanLoganBH

    Using findAny cursor method

    Daniel Cantin

      I am using a sort and an IviewCursor to find data in arrayCollection. My goal is to find all lines in the arrayCollection matching a specific combination of keys. So I use the findAny method of my cursor to do it. As I can see in debug mode only the last occurrence of my keys combination trigger the function code of my listener.

       

      Here is my code:

       

      var data:Object              = DataGridListData(listData);

      var indicePaire:int          = new int();

      var startDate:Date           = null;

      var totLigne:String          = new String();

      var pairesSort:Sort          = new Sort();

      var pairesCursor:IViewCursor = this.document.lesPairesWork.createCursor();

      var initConfirme:String      = "1";

      var myKostl:String           = "1";

                         

      theIndice  = event.currentTarget.id.substr(event.currentTarget.id.length-1,1);

      startDate  = lasseUtiGenerale.trsfStringToDate(this.document.formatDate, this.document.dateDebutFLEX);

      dateTraite = dateField.dateToString(classeUtiGenerale.dateMouvement(startDate,theIndice),"YYYYMMDD");

      dateTraiteSAP        = dateTraite;

                         

      data                 = data.item;

      noMatriculePaires    = data["Matricule"];

      totLigne             = data["TypeLigne"];

       

      this.document.pairesTempsOri.removeAll();

       

      pairesSort.fields = [ new SortField( "PernrChar", true ), new SortField( "ZcatsdateChar", true ), new SortField( "Statut", true ),  new SortField( "StatutKostl", true ) ];

                         

      this.document.lesPairesWork.sort = pairesSort;

                         

      this.document.lesPairesWork.refresh();

       

      pairesCursor.addEventListener( FlexEvent.CURSOR_UPDATE, addPaireHeures );

                         

      pairesCursor.findAny( { PernrChar:noMatriculePaires, ZcatsdateChar:dateTraite, Statut:initConfirme, StatutKostl:myKostl } );

       

      I am not an expert of Flex and maybe I am not using the good way to get what I want.

       

      Help required.

       

      Regards,

        • 1. Re: Using findAny cursor method
          DeanLoganBH Level 3

          Trying see if I understand your issue.  When you use findAny, you get the same result each time?

          You will always only get 1 item returned.

           

          findAny(values:Object):Boolean

          Finds an item with the specified properties within the collection and positions the cursor to that item.

          findFirst(values:Object):Boolean

          Finds the first item with the specified properties within the collection and positions the cursor to that item.

          findLast(values:Object):Boolean

          Finds the last item with the specified properties within the collection and positions the cursor on that item.

           

          If you want to find all the items, you probably need to use the Bookmark and Seek functions to move through the cursor until you get to the end.