X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/examples/platform/templates.js diff --git a/examples/platform/templates.js b/examples/platform/templates.js new file mode 100644 index 00000000..7de9e8b1 --- /dev/null +++ b/examples/platform/templates.js @@ -0,0 +1,75 @@ +Ext.require('widget.panel'); + +Ext.onReady(function(){ + var data = { + name: 'Abe Elias', + company: 'Sencha Inc', + address: '525 University Ave', + city: 'Palo Alto', + state: 'California', + zip: '44102', + kids: [{ + name: 'Solomon', + age:3 + },{ + name: 'Rebecca', + age:2 + },{ + name: 'Rebecca 1', + age:0 + }] + }; + + Ext.create('Ext.Panel', { + width: 300, + renderTo: 'template-example', + style: "margin:15px", + bodyStyle: "padding:5px;font-size:11px;", + title: 'Basic Template', + tbar: [{ + text: 'Apply Template', + listeners: { + click: function() { + var panel = this.up("panel"), + tpl = Ext.create('Ext.Template', + '

Name: {name}

', + '

Company: {company}

', + '

Location: {city}, {state}

' + ); + + tpl.overwrite(panel.body, data); + panel.doComponentLayout(); + } + } + }], + html: '

Apply the template to see results here

' + }); + + Ext.create('Ext.Panel', { + width: 300, + renderTo: 'xtemplate-example', + style: "margin:15px", + bodyStyle: "padding:5px;font-size:11px;", + title: 'XTemplate', + tbar: [{ + text: 'Apply Template', + listeners: { + click: function() { + var panel = this.up('panel'), + tpl =Ext.create('Ext.XTemplate', + '

Name: {name}

', + '

Company: {company}

', + '

Location: {city}, {state}

', + '

Kids: ', + '', + '

{#}. {parent.name}\'s kid - {name}

', + '

' + ); + tpl.overwrite(panel.body, data); + panel.doComponentLayout(); + } + } + }], + html: '

Apply the template to see results here

' + }); +}); \ No newline at end of file