ListView item template example

2 posts, 1 answers
  1. Ian
    Ian avatar
    129 posts
    Member since:
    Jun 2009

    Posted 15 Jan 2015 Link to this post

    Hi,
    Is there any documentation or example code explaining how to populate a ListView using an item template? I'm interested in a code-only approach (ie. no XML) for now.

    Thanks, Ian
  2. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Jan 2015 Link to this post

    Hello Ian,

    Here is an example:
    var pages = require("ui/page");
    var listViewDef = require("ui/list-view");
    function createPage() {
        var listView = new listViewDef.ListView();
        listView.items = [{ MyProp: 1 }, { MyProp: 2 }, { MyProp: 3 }, { MyProp: 4 }, { MyProp: 5 }];
        listView.itemTemplate = "<StackPanel><Label text='{{ MyProp }}'></StackPanel>";
        var page = new pages.Page();
        page.content = listView;
        return page;
    }
    exports.createPage = createPage;


    Regards,
    Vlad
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top