我有一个 tabular form
我想用不同颜色显示列增量的值。 Delta 是 column1 和 column2 之间的差异,这是我动态生成的。
如果增量值为>0
颜色没有变化,如果 delta 是 <0
如果值为 0
,则该值应为红色,否则为绿色.
我正在使用 Oracle APEX 版本:4.2.1
最佳答案
我前段时间遇到过类似的问题,我的做法是:
首先声明一个css类
.cellColored{background-color:#ff0000 !important}
/*notice the !important attribute, if not declared the browser will use the apex css definition*/
然后转到您的表格形式定义 -> 区域定义 -> 属性 在静态 ID 中添加和 id 是这样的:
tab_form_id
然后转到表格表单定义中的报告属性并编辑要绘制的列,在“元素属性”字段中添加:class='classDelta'
然后运行一个 javascript 函数将 cellColored 类分配给符合条件的表格单元格,如下所示:
function paintCells(){
var tabForm = document.getElementById('tab_form_id');
var cells = tabForm.getElementsByTagName('td');
for(var i = 0; i < cells.length; i++){
if((cells[i].headers === 'DELTA') && (Number(cells[i].getElementsByClassName('classDelta')[0].value) < 0)){
cells[i].className = cells[i].className + ' cellColored';
}
}
}
注意 cells[i].headers === 'DELTA'
行,这应该是报告中定义的列的名称。
编辑
上面是输入类型元素,对于只读列你需要使用这个函数:
function paintCells(){
var tabForm = document.getElementById('tab_form_id');
var cells = tabForm.getElementsByTagName('td');
for(var i = 0; i < cells.length; i++){
if((cells[i].headers === 'DELTA') && (Number(cells[i].innerHTML) < 0)){
cells[i].className = cells[i].className + ' cellColored';
}
}
}
关于javascript - 甲骨文顶点 : Color the values in column of tabular form,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34849969/