我有一个ExtJS TreeGrid,我正在尝试将自定义渲染器添加到特定列.不幸的是它不起作用 - 事件没有被解雇,也没有发出任何警告.我也找不到TreeGrid的API.还有其他人经历过这个吗?
这是代码:
var tree = new Ext.ux.tree.TreeGrid({
title: 'My Tree Grid',
loader: treeLoader,
columns:[{
header: 'Title',
dataIndex: 'title',
width: 500
},{
header: 'Testing',
width: 100,
dataIndex: 'testing',
renderer: function(value) {
console.log('Test');
},
align: 'center'
}]
});
Run Code Online (Sandbox Code Playgroud)
谢谢!
TreeGrid没有API,因为它是用户扩展(Ext.ux).您需要查看源代码以获取更多信息.如果项目中没有源,请转到以下页面:
http://dev.sencha.com/deploy/dev/examples/treegrid/treegrid.html
并点击"查看来源" Ctrl + U
.从那里你可以链接到TreeGrid.js
和其他支持js文件.
我注意到TreeGrid
延伸TreePanel
,这反过来延伸了原来的Panel
.似乎没有任何引用GridPanel
,所以如果您使用该组件,我不相信有任何列渲染器.从我收集的内容来看,示例(tree-grid.js)使用XTemplate来渲染列数据:
var tree = new Ext.ux.tree.TreeGrid({
title: 'Core Team Projects',
width: 500,
height: 300,
renderTo: Ext.getBody(),
enableDD: true,
columns:[{
header: 'Task',
dataIndex: 'task',
width: 230
},{
header: 'Duration',
width: 100,
dataIndex: 'duration',
align: 'center',
sortType: 'asFloat',
// ================================== //
// this acts as your column renderer
tpl: new Ext.XTemplate('{duration:this.formatHours}', {
formatHours: function(v) {
if(v < 1) {
return Math.round(v * 60) + ' mins';
} else if (Math.floor(v) !== v) {
var min = v - Math.floor(v);
return Math.floor(v) + 'h ' + Math.round(min * 60)
+ 'm';
} else {
return v + ' hour' + (v === 1 ? '' : 's');
}
}
})
// ================================== //
},{
header: 'Assigned To',
width: 150,
dataIndex: 'user'
}],
dataUrl: 'treegrid-data.json'
});
Run Code Online (Sandbox Code Playgroud)
尝试使用XTemplate为您的目的.如果这不符合您的需求,您将不得不提供更多信息.
归档时间: |
|
查看次数: |
5677 次 |
最近记录: |