locked
How to add a item to the beginning of a ListView with javascript RRS feed

  • Question

  • Hi,

    I'm bulding an app, in which i use a ListView with a grid-layout.. I dynamicly insert items into this ListView. But, how can I insert an item at the beginning of the ListView?

    I know it can be done - the mail app preview inserts at the beginning of the ListView, when new emails are found.. I just can't found out how..

    I know I can add and remove items from the datasource object, but as I understand, I only can add to the far end of ListView..

    Can anyone help?

    /fMads

    Saturday, March 24, 2012 11:16 AM

Answers

  • Nevermind - I figured it out.

    To others with the same problem

    // API
    listView.insertBefore(null, data, key);
    
    // fx
    listView.insertBefore(null, {
        title: 'Title',
        summary: 'Bla bla bla'
    }, '1');
    // Inserts the item at the before the first item in the list

    Saturday, March 24, 2012 3:29 PM