listView ensureVisible not positioning correctly


  • Hi All

    I'm trying to get my listview to show the currently selected item, to do this I am using ensureVisible which kind of works. However it doesn't really work all too well, the reason for this is that the further down the list the items are the less chance of ensureVisible working correctly, it seems to be making the call before all the list layout calculations have been completed. I can get it to work by putting the handler inside of a setTimeout(wrapped in msSetImmediate) but clearly this isn't ideal. 

    Any advice or examples of how to this properly?

            listView = listView.winControl;
            listView.itemDataSource = groupedList.dataSource;
            listView.itemTemplate = TrxnItemTemplate;
            listView.groupDataSource = groupedList.groups.dataSource; 
            listView.groupHeaderTemplate = headertemplate;
            msSetImmediate(function () {
                if (ViewData.trxnsData.currentSelectedIndex !== "selectNone") { }
                var selectedIndex = parseInt(ViewData.trxnsData.currentSelectedIndex);
                setTimeout(function () {
                }, 200);

    • Edited by Syllogism Monday, October 08, 2012 7:29 AM typos
    Friday, October 05, 2012 1:17 PM