23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Again, we have the same use of WinJS.Binding.Template and various bits of data-binding syntax<br />

sprinkled around the markup, not to mention the click handler assigned to the header text itself,<br />

which, like an item in snapped view, navigates to the group detail page.<br />

As for the data itself (that you’ll likely replace), this is again defined in js/data.js as an in-memory<br />

array that feeds into WinJS.Binding.List. In the sampleItems array each item is populated with inline<br />

data or other variable values. Each item also has a group property that comes from the sampleGroups<br />

array. Unfortunately, this latter array has almost identical properties as the items array, which can get<br />

confusing. To help clarify that a bit, here’s the complete property structure of an item:<br />

{<br />

}<br />

group : {<br />

key,<br />

title,<br />

subtitle,<br />

backgroundImage,<br />

description<br />

},<br />

title,<br />

subtitle,<br />

description,<br />

content,<br />

backgroundImage<br />

As we saw with the ListView grouping sample earlier, the Grid App project template uses<br />

createGrouped to set up the data source. What’s interesting to see here is that it sets up an initially<br />

empty list, creates the grouped projection (omitting the optional sorter function), and then adds the<br />

items by using the list’s push method:<br />

194

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!