EXTJS网格行着色失败

时间:2013-07-23 10:10:31

标签: javascript css extjs grid extjs3

我正在使用extjs 3.2。我刚刚参考http://skirtlesden.com/articles/styling-extjs-grid-cells尝试了一个网格行着色示例。在gridExample.js文件中添加了网格视图配置,该文件包含静态网格。

    viewConfig: { 
    stripeRows: false, 
    getRowClass: function(record) { 
        return record.get('age') < 18 ? 'child-row' : 'adult-row'; 
    } 

并在html页面中添加了CSS。

HTML代码是,

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>success</title>
<link href="/testing/ext/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
<link href="/testing/ext/resources/css/test.css" rel="stylesheet" type="text/css" />
<style>
.child-row .x-grid-cell { 
    background-color: #ffe2e2; 
    color: #900; 
}  
.adult-row .x-grid-cell { 
    background-color: #e2ffe2; 
    color: #090; 
}
</style>
<script src="/testing/ext/adapter/ext/ext-base.js"></script>
<script src="/testing/ext/ext-all.js"></script>
<script src="/testing/JS/gridExample.js"></script>
</head>
<body>
</body>
</html>

但网格行颜色没有改变。大多数论坛都确定代码。那么,html页面中的css是否有任何问题?提前谢谢。

2 个答案:

答案 0 :(得分:1)

Ext 3.x使用x-grid3-...形式的CSS类作为网格元素。 您可以检查this 3.2 example的标记以便自己查看。

所以,你的CSS应该是:

.child-row .x-grid3-cell { 
    background-color: #ffe2e2; 
    color: #900; 
}  

答案 1 :(得分:0)

我必须向这些属性添加!important以获得类似的功能。

.child-row .x-grid-cell { 
    background-color: #ffe2e2 !important; 
    color: #900 !important; 
}