我在extjs工作。我想用不同的颜色显示不同的记录。我在回调函数中加载存储和检索记录
taskStore.load({
url : URL_TASK,
callback: function(records, operation, success) {
if(success) {
for(var i = 0; i < records.length; i++) {
records[i].set('Cls', 'assignedTasksCls');
}
}
}
});对于每个记录,我将Cls=设置为"assignedTasksCls",我将其定义为:
.assignedTasksCls {
background-color: #51c063;
border: 1px solid #8cd191;
border-radius: 5px;
box-shadow: 1px 1px 2px rgba(150, 150, 150, 0.5);
height: 90%;
left: -6px;
line-height: 7px;
position: relative;
}我想改变这个类的背景颜色属性,因为需要为不同的记录设置不同的颜色。我可以得到这个css via= recordsi.getCls();那么如何用每条记录更新这个类的“背景色”呢?
发布于 2014-05-21 19:09:39
发布于 2014-05-21 15:28:40
改变背景颜色的方法是
通过JQuery
$("#YourSelector").css("background-color", "yellow");通过Extjs支持
<div id="div1">My Div 1</div>然后
Ext.onReady(function() {
Ext.get('div1').setStyle('color', 'red');
});对于类方法使用
records[i].addCls("assignedTasksCls");
records[i].removeCls("assignedTasksCls")很好的示例from here
另外,我发现一个很好的例子可能对你的情况很有用,请check from here
发布于 2014-05-21 17:33:17
看看this example,它做的正是你所需要的。
https://stackoverflow.com/questions/23776646
复制相似问题