gpt4 book ai didi

javascript - 如何在 extjs 或 javascript 中创建动态 CSS 类

转载 作者:数据小太阳 更新时间:2023-10-29 06:12:44 24 4
gpt4 key购买 nike

是否可以在 extjs 中为 GridView 创建动态 css 类,而无需在样式表中硬编码 css 类,例如

 DEFAULT_ROW_COLOR = '#E0E0E0';
...
var gridview = new Ext.grid.GroupingView({
forceFit : forceFit,
hideGroupedColumn : true,
showGroupName : false,
groupTextTpl: '{text}',
getRowClass : getRowClassFunc
});

var getRowClassFunc = function(record, rowIndex, rowParams, store) {
if (rowIndex == 1 ) {
// create a dynamic class based on DEFAULT_ROW_COLOR for background color
}
if (rowIndex > 1) {
// create a dynamic class for darker color for the background.
}
};

最佳答案

你可以使用 Ext.util.CSS.createStyleSheet (在 ExtJS 3.4 和 ExtJS 4.1 中都可用)正是为了这个目的。

示例:

Ext.util.CSS.createStyleSheet(
'.some-row-class {background-color:' + DEFAULT_ROW_COLOR + ';}'
);

关于javascript - 如何在 extjs 或 javascript 中创建动态 CSS 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11926021/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com