javascripthtmlwindows-8visual-studio-2012winjs

How can I identify a specific property in a Grip App Template?


I'm developing an App for Windows Store and I have done some changes in the code the first one in data.js:

var sampleItems = [
        { group: sampleGroups[0], itemClass: "item2", title: "Pupusas:", subtitle: "Item Subtitle: 1", description: itemDescription, content: itemContent, backgroundImage: "/images/dishes/horizontal/comidas.jpg" },
        { group: sampleGroups[0], itemClass: "item", title: "Atol Shuco:", subtitle: "Item Subtitle: 2", description: itemDescription, content: itemContent, backgroundImage: "/images/dishes/thumbnails/bebidas/atol_shuco.jpg" },
        { group: sampleGroups[0], itemClass: "item", title: "Pan con Pollo:", subtitle: "Item Subtitle: 3", description: itemDescription, content: itemContent, backgroundImage: "/images/dishes/thumbnails/comidas/pan_pollo.jpg" },
        { group: sampleGroups[0], itemClass: "item", title: "Nuegados de Huevo:", subtitle: "Item Subtitle: 4", description: itemDescription, content: itemContent, backgroundImage: "/images/dishes/thumbnails/postres/nuegados.jpg" },
        { group: sampleGroups[0], itemClass: "item", title: "Frijoles Borrachos:", subtitle: "Item Subtitle: 5", description: itemDescription, content: itemContent, backgroundImage: "/images/dishes/thumbnails/comidas/frijoles_borrachos.jpg" }];

As you can see I have added a property called itemClass which determinate, the class of CSS that I'm going to use, and this is the result: http://social.msdn.microsoft.com/Forums/getfile/214473

I know it works good but my problem is that all the pictures that you see are items and I need that the larges ones must be groups, I have the codes for groups and items for the groupedItem.js although I don't know how to merge them, this is the codes, both must be in the _initializeLayout: function (listView, viewState) in the else: This is for the items:

            listView.itemDataSource = Data.items.dataSource;
            listView.groupDataSource = Data.groups.dataSource;

This is for the groups:

        listView.itemDataSource = Data.groups.dataSource;
        listView.groupDataSource = null;

I would like to know, how can I identify "item2"? And chose the groups inside of the items.


Solution

  • Use the args.detail.itemIndex for the items index. This is the right way to get the index; the item you're getting from the getAt call is your data item, which unless you've put an index on it, won't have an index property.