首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

ExtJs的XTemplate运用

2012-09-04 
ExtJs的XTemplate使用? ExtJs目前还是很多企业web应用首选的js框架,ext本身提供了很多很好的控件给我们使

ExtJs的XTemplate使用

? ExtJs目前还是很多企业web应用首选的js框架,ext本身提供了很多很好的控件给我们使用了,简单的应用已经能基本满足要求,但是,当我们深度使用Ext后,为了应对一些奇怪的需求,就要使用到一些Ext的秘笈了,其中一个就是XTemplate。什么?你还不知道XTemplate是个什么东西?好吧,let go!

?

? 先介绍一下XTemplate

?

?

?

var data = {name: 'Tommy Maintz',title: 'Lead Developer',company: 'Sencha Inc.',email: 'tommy@sencha.com',address: '5 Cups Drive',city: 'Palo Alto',state: 'CA',zip: '44102',drinks: ['Coffee', 'Soda', 'Water'],kids: [{        name: 'Joshua',        age:3    },{        name: 'Matthew',        age:2    },{        name: 'Solomon',        age:0}]};

?

?

数组处理

?

?

var tpl = new Ext.XTemplate(    '<p>Kids: ',    '<tpl for=".">',       // process the data.kids node        '<p>{#}. {name}</p>',  // use current array index to autonumber    '</tpl></p>');tpl.overwrite(panel.body, data.kids); // pass the kids property of the data object 

?

?上面就是单独使用XTemplate的过程。

?

?

条件判断

?

The?tpl?tag and the?if?operator are used to provide conditional checks for deciding whether or not to render specific parts of the template. Notes:

});

?

热点排行