ExtJs의 Ext.XTemplate: 템플릿 구성원 함수

2582 단어
<!DOCTYPE html>
<html>
<head>
    <title>ExtJs</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" type="text/css" href="ExtJs/packages/ext-theme-crisp/build/resources/ext-theme-crisp-all.css">
		<script type="text/javascript" src="ExtJs/ext-all.js"></script>
		<script type="text/javascript" src="ExtJs/bootstrap.js"></script>
		<script type="text/javascript" src="ExtJs/packages/ext-theme-crisp/build/ext-theme-crisp.js"></script>

    <script type="text/javascript">
			Ext.onReady(function(){
        var tpl1 = new Ext.XTemplate(
          '<table border=1 cellpadding=1 cellspacing=1>',
          '<tr><td width=90> </td><td width=90> </td></tr>',
          '<tpl for=".">',
          '<tpl if="this.check(wage)">',
          '<tr><td>{name}</td><td>{[this.format(values.wage)]}</td></tr>',
          '</tpl></tpl>',
          '</table>',
          {
            check: function(wage) {
              if (wage >1000){
                return true;
              }else {
                return false
              }
            },
            format: function(wage){
              if(wage> 1300){
                return '<font color=red>' + wage + '</font>';
              }else {
                return '<font color=blue>' + wage + '</font>';
              }
            }
          }
        );
        var tplData = [
          {name: ' ', wage: 1320},
          {name: ' ', wage: 1200},
          {name: ' ', wage: 1556},
          {name: ' ', wage: 1134},
          {name: ' ', wage: 1822}
        ]
        tpl1.append('tpl-table1', tplData);


      });
    </script>
</head>
<body>
<div id='tpl-table1'></div>
<br>
<div id='tpl-table2'></div>
</body>
</html>

좋은 웹페이지 즐겨찾기