jason
jason

Reputation: 1631

Disable auto adjust selectIndex after ArrayCollection refresh

I also post the question on flex community.

The issue is when List dataProvider has ISort property, after change the removed item property and refresh the ArrayCollection, even set list.selectedIndex = -1, the List still has one item selected.

Before remove "43" item:

enter image description here

After remove the "43" item, auto select first item(what I want is the list has no selected item and no caret item):

enter image description here

Upvotes: 0

Views: 47

Answers (1)

jason
jason

Reputation: 1631

I found a workaround. Remove the items then change property.

Modify the function as following:

 private function removeLast():void {

            var lastItem:Object = _dataProvider.getItemAt(_dataProvider.length -1);
            //remove the item
            _dataProvider.removeItemAt(_dataProvider.getItemIndex(lastItem));
            // then change property
            lastItem.digit = -100;

            // Note: MUST refresh
            _dataProvider.refresh();
            // do other stuff
            list.selectedIndices = new Vector.<int>();
            list.selectedIndex = -1;

        }

Upvotes: 0

Related Questions