Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-23933

not possible to set dataProvider and immediately thereafter set horizontalScrollPosition to see the item I expect

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Adobe Flex SDK 4.0 (Release)
    • None
    • mx: List
    • None
    • Affected OS(s): Windows
      Affected OS(s): Windows
      Browser: Firefox 3.x
      Language Found: English

    Description

      Note: I am running the Flex 4 build 272416

      Steps to reproduce:

      1. Create an spark Application
      2. In that Application, put a spark List
      3. Give the spark list a horizontal layout with justified content and a columnWidth that will result in an even number of items on a "page"
      4. Utilize an item renderer for the list which takes in the incoming data (always strings) and renders a button with that string on the label.
      5. Note that we now have what I call a horizontal button bar. Shows X buttons at a time.
      6. Know that my system input gets a updateable list of 5-1000 buttons strings and one selected button string which is always in that list.
      7. Write a function that simulates an update even which causes dataProvider to change and hsp to update intending to bring selected item into the view of the user (example below)

      // server gives us the list of item names and the name of the selected item (which is a button or image, or whatever)
      // maxItems is the max items to generate
      // itemWidth is the width per item
      private function simulateUpdate(maxItems:uint, itemWidth:Number):void
      {
      var listDataProvider:ArrayList = new ArrayList();
      var numItems:uint = (int)(Math.random() * maxItems); // we generate a number of items to generate
      var selectedItemIndex:uint = (int)(Math.random() * numItems); // we get a randomly selected index from that number

      // we "spoof" generate the btn names (just random numbers)
      for (var x:uint=0; x<numItems; x++)

      { var str:String = Math.random().toString(); listDataProvider.addItem(str); }

      yourListId.dataProvider = listDataProvider; // that array is now our data provider, itemRenderer should do it's work
      yourListId.selectedIndex = selectedItemIndex; // we set the list selected index
      yourListId.scroller.viewport.horizontalScrollPosition = selectedItemIndex * itemWidth; // and change the hsp to put selected item in view
      }

      then call this function somehow..

      Actual Results:

      A horizontal scroll position (hsp) of near 0 (even though it is being set to a number that is not 0)
      It's like the hsp didn't take
      I'm seeing huge scrollbar handles and when I drag them around they get smaller and smaller.
      It's almost as if it hasn't truly measured the content height.
      After the handles are smaller if I generate a small number of items, I often to get the hsp to really be where it should.
      This makes me feel that the contentWidth and contentHeight of the viewport gets larger as you look at more stuff in the list?
      I can't directly access the viewport or scroller to set that content height as list does it automatically (as far as I know)...
      I tried a bunch of invalidates.. no go.
      Tweening to the value works better, but, I have to put enough time on that tween if I want it to be reliable.
      And I don't want to tween, I want this to work instantaneously.

      Expected Results:

      I expect to see, every time, in my list, all of my items, and of course, the "selected item" being the first item visible to the user.

      Workarounds:

      Basically none. I've tried all kinds of validates and invalidates - dont work. I've tried ensureIndexIsVisible and that crashes because it says the index is invalid.

      Attachments

        Activity

          People

            Unassigned Unassigned
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: