问题描述
我正在尝试使用 reset(json_decode($_POST['tableFields'],1));
文档中的 Ext.grid.Grid
示例。我无法弄清楚为什么 extJS
也将 tpl
元素也显示为文本。
div
Ext.create('Ext.data.Store',{
storeId:'employeeStore',fields:['firstname','lastname','seniority','department'],groupField: 'department',data:[
{ firstname: "Michael",lastname: "Scott",seniority: 7,department: "Management" },{ firstname: "Dwight",lastname: "Schrute",seniority: 2,department: "Sales" },{ firstname: "Jim",lastname: "Halpert",seniority: 3,{ firstname: "Kevin",lastname: "Malone",seniority: 4,department: "Accounting" },{ firstname: "Angela",lastname: "Martin",seniority: 5,department: "Accounting" }
]
});
Ext.create('Ext.grid.Grid',{
title: 'Column Template Demo',store: Ext.data.StoreManager.lookup('employeeStore'),columns: [{
text: 'Full Name',tpl: '{firstname} {lastname}'
},{
xtype: 'templatecolumn',text: 'Department (Yrs)',tpl: '<div class="test">{department} {seniority}</div>'
}],height: 200,width: 300,renderTo: Ext.getBody()
});
我希望 Output
不应该显示。我在这里遗漏了什么吗?
解决方法
在现代工具包中,单元格内容默认是 html 编码的。对于您的情况,您需要将单元格的 encodeHtml 配置设置为 false:
{
xtype: 'templatecolumn',text: 'Department (Yrs)',tpl: '<div class="test">{department} {seniority}</div>',cell: {
encodeHtml: false
}
}