23

Advanced Templates for Ext JS

  • Upload
    sencha

  • View
    18.989

  • Download
    3

Embed Size (px)

DESCRIPTION

In this session you'll learn how to go beyond basic templating and harness the power of XTemplate to create complex, data-bound HTML. We'll show you how to use XTemplate in ways you didn't think were possible. Among other topics, we'll look at Javascript member functions, recursive templates, subtemplates, and layouts for lists.

Citation preview

Page 1: Advanced Templates for Ext JS
Page 2: Advanced Templates for Ext JS

Advanced Templatesfor Ext JS

James Brantly @jbrantly

Page 3: Advanced Templates for Ext JS

Overview

Page 4: Advanced Templates for Ext JS

Overview

Member FunctionsSubtemplates

Recursive TemplatesList Layout

Page 5: Advanced Templates for Ext JS

Crash Course

Page 6: Advanced Templates for Ext JS
Page 7: Advanced Templates for Ext JS

Member Functions

Page 8: Advanced Templates for Ext JS

Member Functions• Arbitrary JavaScript functions can be defined and

executed as part of the template• Extremely useful for adding advanced functionality and

all of the techniques shown today will use them• Defined by passing a config object as last parameter and

attaching functions as properties• Three basic ways of accessing member functions from

template

Page 9: Advanced Templates for Ext JS
Page 10: Advanced Templates for Ext JS

Subtemplates

Page 11: Advanced Templates for Ext JS

Subtemplates• Templates can call other templates• Great if there is a lot of redundancy in your templates• Makes use of the “apply” method• Can optionally create a “manager” class to name and

easily access subtemplates

Page 12: Advanced Templates for Ext JS
Page 13: Advanced Templates for Ext JS
Page 14: Advanced Templates for Ext JS

Recursive Templates

Page 15: Advanced Templates for Ext JS

Recursive Templates• Uses the same methodology as subtemplates: templates can

call other templates, even themselves• Great for hierarchical/nested data

Page 16: Advanced Templates for Ext JS
Page 17: Advanced Templates for Ext JS

List Layout

Page 18: Advanced Templates for Ext JS

List Layout• Templates are often used to create lists (ex. DataView)• Typically laid out using normal flow (inline or block) or

stacked next to each other using float• It’s possible using the “xindex” variable and the modulo

operator to create wrapper elements around groups of items for more advanced layout strategies

Page 19: Advanced Templates for Ext JS
Page 20: Advanced Templates for Ext JS
Page 21: Advanced Templates for Ext JS

Example App

Page 22: Advanced Templates for Ext JS

Questions?

Page 23: Advanced Templates for Ext JS

http://www.sencha.com/deploy/dev/docs/see the Ext.XTemplate constructor

http://www.github.com/jbrantly/advtemplates

[email protected]

Questions?