我正在尝试extJS
文档中的Ext.grid.Grid
示例。我无法理解为什么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, department: "Sales" },
{ 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
我预期<div class="test">
不应该显示。我是否遗漏了什么?
1条答案
按热度按时间23c0lvtd1#
在现代工具包中,单元格内容默认是html编码的。对于您的情况,您需要将单元格的encodeHtml config设置为false: