ExtJS之XTemplate

使用XTemplate可以自定义输出:
var tp_checkbox = new Ext.XTemplate(
  '<table><tr><td>{head}</td></tr></table>',
  '<table><tr><tpl for="item"><td nowrap="nowrap">',
  '<p>{#}、<input type="checkbox" name="item" value ={.}>{.}</p>',
  '<td>&nbsp&nbsp&nbsp</td>',
  '</td></tpl></tr></table>');

简单运用
new Ext.Panel({
  items : [{
     xtype : 'fieldset',
     layout : 'fit',
     title : '题目',
     autoHeight : true,
     buttonAlign : 'right',
     items : item_grid_onedit,
     buttons : [{
        text : '题目预览',
        handler : function() {
          var data ="{head:'"
                     +lPanel.getForm().getValues()['head'] +"'";
          data = data + ",questionItemTitle:['"
          item_grid_onedit.getStore().each(function(rec) {
             data = data + rec.get('title') + "','";
          });
          data = data.substr(0, data.length - 2);
          data = data + "]}";
          data = Ext.util.JSON.decode(data);
          tp_checkbox.overwrite(previewPanelOnEdit.body, data);
        }
     }]
  }]
});

你可能感兴趣的:(java,json,ext)