How to do something after GridLayout is rendered? RRS feed

  • Question

  • I am using a listView control in my Windows8 JavaScript app and I am rendering the items on the page using some code which looks like:

                listView.layout = new ui.GridLayout({
                    groupHeaderPosition: "top",
                    groupInfo: this.groupInfo,
                    itemInfo: this.computeItemSize

    Now I want to do some action after these items are rendered on the page. Any idea where I can set a callback for this?

    Wednesday, October 10, 2012 10:09 AM


  • In your javascript file, find the listview control in your onReady function, something like this:

    Assuming the id of your listview is list1.

    var myList = document.querySelector("#list1");

    if (myList) {myList.winControl.onloadingstatechanged = onLoadingStateChanged;}

    then add an event handler

    var onLoadingStateChanged = WinJS.UI.eventHandler(function(e) {    

    if (e.currentTarget.winControl.loadingState == "complete") {         

    // do whatever you want to do    



    Wednesday, October 10, 2012 5:38 PM