即使我的每个列都设置为固定的像素宽度,我的treegrid列也遍布整个地方(即不是以直线对齐)。请参阅说明问题的screenshot。另外,下面是treegrid代码的概述。有关如何解决此问题的任何想法?
var currentdate = new Date();
var currenthour = currentdate.format('G');
var intcurrenthour = parseInt(currenthour);
intcurrenthour = intcurrenthour + 1;
var currentday = currentdate.format('D M j Y');
var basecolor = "#FFFFFF";
var currentcolor = "#F0F0F0";
var i = 0;
var x;
function fn(v, values){
if(i == 3){i = 0}
i = i + 1;
switch(i){
case 1: x = values.alarm1; break;
case 2: x = values.alarm2; break;
case 3: x = values.alarm3; break;
default: alert("x not assigned value");
}
if (x == 1) {return '<span style="background-color: red; width: 100%">' + v + '</span>';}
else if(i == intcurrenthour)
{return '<span style="background-color:' + currentcolor + '; width: 100%">' + v + '</span>';}
else
{return '<span style="background-color:' + basecolor + '; width: 100%">' + v + '</span>';}
}
var TDCurrentDay = new Ext.ux.tree.TreeGrid({
title: currentday,
requestMethod : 'GET',
margins: '5 5 0 5',
height: 400,
collapsible:false,
region:'center',
autowidth: false,
headersDisabled: true,
viewConfig:{forceFit:true},
tbar: {
xtype: 'toolbar',
items: [
{xtype: 'button',text: 'Expand All', icon:'../images/expand-all.gif',
handler: function(){
TDCurrentDay.expandAll();
}
},
{xtype: 'spacer',width:5},
{xtype: 'button',text: 'Collapse All', icon:'../images/collapse-all.gif',
handler: function(){
TDCurrentDay.collapseAll();
}
}
]
},
enableDD: false,
columns:[
{header: 'Unit',dataIndex: 'unit', width: 210},
{header: 'H1', width: 60, dataIndex: 'duration1', align: 'center',
tpl: new Ext.XTemplate('{duration1:this.doFormat}', {
doFormat: fn
})
},
{header: 'A1', width: 0,dataIndex: 'alarm1', visibility: false},
{header: 'H2', width: 60, dataIndex: 'duration2', align: 'center',
tpl: new Ext.XTemplate('{duration2:this.doFormat}', {
doFormat: fn
})
},
{header: 'A2', width: 0,dataIndex: 'alarm2', visibility: false},
{header: 'H3', width: 60, dataIndex: 'duration3', align: 'center',
tpl: new Ext.XTemplate('{duration3:this.doFormat}', {
doFormat: fn
})
},
{header: 'A3', width: 0,dataIndex: 'alarm3', visibility: false}
],
dataUrl: 'treegrid-data.json'
});
答案 0 :(得分:1)
在Sencha支持的帮助下,通过删除treegrid.css文件修复了该问题,该文件由于某种原因导致了列对齐问题,并为单元格边框添加了以下代码:
.x-treegrid-col {
border: 1px solid #efefef;
}
答案 1 :(得分:0)
您是在谈论网格中项目的对齐方式吗?
从列定义中删除align: 'center'
会使它们保持对齐状态。您可能更喜欢align: 'right'
。
答案 2 :(得分:0)
我猜你在谈论缩进的树形结构?显然存在显示遏制,如果没有惊人,很难看出哪些节点在其他节点下。
但如果这实际上是你想要的,你可以通过给你的TreeGrid一个CSS类隐藏缩进,然后将它添加到你的CSS文件中:
<style type="text/css">
.my-tree-grid-class .x-tree-node-indent { display: none; }
</style>