ScrollToIndex doesn't work when dataprovider has just been updated

I experienced a problem with a datagrid where I tried to use a scrollToIndex.

This was the necessary workflow:

The selectedIndex worked, the scrollToIndex not.

The answer is simple once you know it: add dg.validateNow() before calling the scrollToIndex !

Example without the validateNow
–> this datagrid gets really messy with the second button clicked!

Example with the validateNow
–> everything ok here!

This is the code:

not working:

click="dgTest.selectedIndex=7; dgTest.scrollToIndex(7);" 

working:

click="dgTest.dataProvider=[]; dgTest.dataProvider=employees; dgTest.validateNow(); dgTest.selectedIndex=7; dgTest.scrollToIndex(7);"