1 Reply Latest reply on Jan 16, 2008 2:34 PM by shawnyale

    IViewCursor through nested XMLListCollection

    shawnyale
      Hi all,
      I have an xmlListCollection that follows the following format:
      <customer id="1">
      <customer/>
      <customer id="2">
      <customer id="3"/>
      <customer id="4"/>
      </customer>
      </customer>
      where customer 3 & 4 are nested below customer 2, and where customer 2 is nested below customer 1. I have read almost every document on the web and have followed the directions exactly but still cant get my cursor to find a specific customer by id#. When I run the cursor, it looks like it is only looking at the top level node and even then its not returning the node event though the id's match.

      this is what my code looks like:

      protected function handlerButton_Click(searchValFromTextField:Object):void{
      var temp:Object = searchTree(searchValFromTextField);
      if(temp != null){
      someTreeControl.selectedItem = temp;
      }
      }

      protected searchTree(item:Object):Object
      {
      sortItems();
      var cursor:IViewCursor = dataSourceXMLListCollection.createCursor();
      var found:Boolean = cursor.findAny({"@id":item});
      if(found){
      return cursor.current;
      }else{
      return null;
      }
      }
      protected function sortItems():void
      {
      var treeSort:Sort = new Sort();
      treeSort.fields = [new SortField("@id", true)]; // This is how the documentation said to sort on an attribute (doesnt work)
      dataSourceXMLListCollection.sort = treeSort;
      dataSourceXMLListCollection.refresh();
      }

      It doesnt look like my XMLListCollection is even getting sorted. This collection comes with its heirarchy from the db. I have tried tons of different ways to get this to sort and to compare the values that the user passes in and those in the data source XMLListCollection.

      The documentation states that the cursor will traverse all of the items in the data source, but it looks like its only looking at the outer-most wrapper node (which contains all of the others).

      I would LOVE to know if this is a known problem and if anyone could offer a way to get this to work correctly so that I can get allow users to look at other users and find them quickly without having to open all of the sub-nodes and manually search for a customer.

      Thank you many times over.