I wrote a search function for a datagrid component. The
dataprovider is a ArrayCollection variable. If the item is found in
the array, set the item to be selected in the datagrid. The problem
is when the selected item is at bottom of the datagrid, the
scrollbar doesn't refresh so I have to manually move the scrollbar
to see the selected item. Here is part of my code:
......(populate accountData using dataservice)
You need to look at the API for DataGrid. Particularly the
The logic in your expectation that setting selectedIndex
should update the scroll position is flawed. What if you selected
an item with the mouse and then wanted to browse the other options?
You would use the scroll bar for this. Your selection might
disappear from the list but you would want it to stay selected.
Thus the scroll position and the selected index are completely
independent of one another.
The point I am trying to make is this: you are required to
set the verticalScrollPosition when you set selectedIndex if you
want them to work in concert.
Thank you for your help! In my case, the datagrid has nothing
but a long list of accounts. That's why i need to write a search
function for it. I found the "verticalScrollPosition" property,
it's inherited from the ScrollControlBase class. I added one line