How to get scroll to a list item in a page that has multiple lists
<p>I have three lists in a page where when one item is selected the other item cannot be selected in other lists. I have written code that focuses on the selected list item when I navigate to that page. Now, the issue is that it's not focusing and <code>addEventDelegate</code> isn't working for the lists. The focus code is getting executed and again the scroll bar is moving to the top.</p>

<p>Initially I tried like this:</p>

<pre><code>tList.addEventDelegate({
    onAfterRendering: function() {
        debugger;
        var a = sap.ui.getCore().byId("typesList").getSelectedItems()[0];
        if(a != undefined) { 
            $("#"+a.sId)[0].focus();
        }
    }
}, this)
cList.addEventDelegate({
    onAfterRendering: function() {
        debugger;
        var a = sap.ui.getCore().byId("catList").getSelectedItems()[0];
        if(a != undefined) { 
            $("#"+a.sId)[0].focus();
        }
    }
}, cList)
sList.addEventDelegate({
    onAfterRendering: function() {
        debugger;
        var a = sap.ui.getCore().byId("statList").getSelectedItems()[0];
        if(a != undefined) { 
            $("#"+a.sId)[0].focus();
        }
    }
}, sList)
</code></pre>

<p>It didn't work. <code>onAfterRendering</code> is never getting fired. I tried this:</p>

<pre><code>onRouteMatched: function(oEvent) {
    debugger;
    var tList = sap.ui.getCore().byId("typesList");
    var cList = sap.ui.getCore().byId("catList");
    var sList = sap.ui.getCore().byId("statList");
    var typesItem = sap.ui.getCore().byId("typesList").getSelectedItems()[0];
    if(typesItem != undefined) { 
        $("#"+typesItem.sId)[0].focus();
    }
    var catItem = sap.ui.getCore().byId("catList").getSelectedItems()[0];
    if(catItem != undefined) { 
        var i = cList.indexOfItem(catItem);
        //$("#"+catItem.sId)[0].focus();
        cList.getItems()[i].focus(); 
    }
    var statItem = sap.ui.getCore().byId("statList").getSelectedItems()[0];
    if(statItem != undefined) { 
        $("#"+statItem.sId)[0].focus();
    }
}
</code></pre>

<p>It's working well but I don't know why the scroll bar is moving to the top of the view after executing this code.</p>

<p>Any suggestions?</p>