如何根据另一个单元格中的值格式化 ExtJS 树网格单元格
我正在尝试根据同一行中另一个单元格中的值来格式化一个 ExtJS 树形网格单元格。下面是我目前如何编码的概述。然而,这目前不起作用,所以我将不胜感激任何建议。谢谢!
function fn(v, values){
if (values.alarm == 1) {
return '<span style="color: red;">' + v + '</span>';
}
return v;
}
//new treegrid
columns:[{
header: 'H1',
width: 60,
dataIndex: 'duration1',
align: 'center',
tpl: new Ext.XTemplate(
'{duration1:this.doFormat}',
{doFormat: fn()}
)
}, {
header: 'A1',
width: 60,
dataIndex: 'alarm1',
align: 'center'
}]
I am trying to format one ExtJS treegrid cell based on the value in another cell in the same row. Below is an overview of how I currently have it coded. However, this is not currently working so I would appreciate any suggestions.Thanks!
function fn(v, values){
if (values.alarm == 1) {
return '<span style="color: red;">' + v + '</span>';
}
return v;
}
//new treegrid
columns:[{
header: 'H1',
width: 60,
dataIndex: 'duration1',
align: 'center',
tpl: new Ext.XTemplate(
'{duration1:this.doFormat}',
{doFormat: fn()}
)
}, {
header: 'A1',
width: 60,
dataIndex: 'alarm1',
align: 'center'
}]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是我开发的解决方案,以便在其他人遇到相同问题时获得所需的内容。
Below is the solution I developed to get what I needed in case anyone else has the same issue.
ExtJS 树网格有点不寻常,因为它并没有得到真正的支持,预计直到 ExtJS 4 才会得到完全支持,此外,XTemplate 文档也有点缺乏。
使用以下模板格式可能会更好:
The ExtJS tree grid is a bit unusual in that it isn't really supported, and is not expected to be fully supported until ExtJS 4, and, in addition, the XTemplate documentation is a bit lacking.
You may have better luck with the following template format: