Ext.元素模板(Template)

<table border="1">
    <tbody id="some-element">
        <tr>
            <td>id</td>
            <td>sex</td>
            <td>name</td>
            <td>descn</td>
        </tr>	
    </tbody>
</table>
<mce:script type="text/javascript"><!--
    Ext.onReady(function(){
        var data = [
            ['1','   nale ','name1','descn1'],
            ['2','female','name2aaaaaaaaaaaaaa','descn2dddddddddddddddd'],
  	   ['3','nale','name3','descn3'],
  	   ['4','female','name4','descn4']
        ];
	  	var t = new Ext.Template(
		    '<tr>',
		        '<td>{0}</td>',
		        '<td>{1:trim}</td>',
		        '<td>{2:this.name}</td>',
		        '<td>{3:ellipsis(6)}</td>',
		    '</tr>'
		);
		t.name = function(value){
			return "<h1>"+value+"</h1>"
		}
		t.compile();
		for(var i=0;i<data.length;i++)
		t.append('some-element', data[i]);
  	})
  
// --></mce:script>

你可能感兴趣的:(Ext.元素模板(Template))