使用JavaScript(DA)更改Oracle APEX交互式网格的行背景颜色。

huangapple go评论75阅读模式
英文:

Change background color row on Oracle APEX interactive grid using Java Script (DA)

问题

我需要在交互式网格中更改一个背景行(使用JavaScript),当idf_type_conv的数据大于0且不等于73和不等于100时。

我使用了以下代码,但没有成功:

$('td[headers="idf_type_conv"]').each(function() {
    if($(this).text() == '0'){
        $(this).closest('tr').find('td').css({"background-color":"red"});
    }
});
英文:

I need to change a background row in Interactive grid (USING JAVA SCRIPT) when a data of idf_type_conv are > 0 and <> 73 and <> 100.

O using this code but I don't have success...

$('td[headers]="idf_type_conv"]').each(function() {
    if($(this).text() == '0'){
        $(this).closest('tr').find('td').css({"background-color":"red"});
    }
});

答案1

得分: 0

由于您没有提到您有任何特殊情况需要处理,我建议使用原生方法:

  1. 在交互式网格的操作菜单中,点击“格式”。在格式中,我们有一个选项可以进行高亮显示。首先,我们需要选择高亮显示。
    使用JavaScript(DA)更改Oracle APEX交互式网格的行背景颜色。

  2. 在高亮窗口中,您需要定义规则以及是要高亮显示行还是特定列。您还可以相应地选择颜色。
    使用JavaScript(DA)更改Oracle APEX交互式网格的行背景颜色。

注意:在保存您的高亮规则之后,确保将交互式网格报告保存为公共报告,您还可以创建多个规则以获得多个规则/颜色。

英文:

As you don't mention that you have any special case to handle, I suggest to use the native method:

  1. In the action menu of the interactive grid, click format.In format we have the option to highlight.First we needs to select highlight.
    使用JavaScript(DA)更改Oracle APEX交互式网格的行背景颜色。

  2. On the highlight window, you need to define rules and whether the row or a specific column would be highlighted. You can also select colors accordingly.
    使用JavaScript(DA)更改Oracle APEX交互式网格的行背景颜色。

Note: After you save your rules to highlight, make sure you save the interactive grid report as public and you can also create multiple rules to have multiple rules/colors.

答案2

得分: 0

高亮方法并不是一个坏的解决方案,但是如果你不想使用内置的功能,这里有另一种解决方案。

基本上,你需要在每个你想要着色的列上使用这段代码(代码必须放置在JavaScript初始化代码属性部分):

function(options) {
    options.defaultGridColumnOptions = {
        cellCssClassesColumn:"idf_type_conv"
    }
    return options;
}

在这个例子中,"idf_type_conv"是一个情况,当列是报表源查询时,它确定所需颜色的CSS类。例如,如果你有一个页面级别的自定义CSS类叫做"RED",你的情况语句会像这样:

case when idf_type > 0 then 'RED' end as idf_type_conv

你可以在页面级别的内联CSS区域指定所需的CSS类,像这样:

.RED{ 
    background-color: red;
}
英文:

The Highlight method is not a bad solution but, if you don't want to use the built-in, feature here is another solution.

Basically, you have to use this piece of code on every column you want to color (the code must be placed in the JavaScript Initialization Code attribute section):

function(options) {
    options.defaultGridColumnOptions = {
        cellCssClassesColumn:"idf_type_conv"
    }
    return options;
}

In this example, the "idf_type_conv" is a case when column is the report source query which determines the CSS class for the color you need. For example, if you have a page level custom CSS class called "RED" your case when would look like this:

case when idf_type > 0 then 'RED' end as idf_type_conv

You can specify the needed CSS class on the page level Inline CSS region, like this:

.RED{ 
    background-color: red;
}

答案3

得分: 0

我设法使它工作了。

然而,我没有时间对代码进行注释,但它并不难,使用console.log在变量中可以让你了解正在发生的事情。

我需要测试两个数据的值(在这种情况下是第32列和第33列),所以APEX的原生模式无法工作。

(请按照下面的代码(在执行JavaScript代码中)):

var ig$ = apex.region("grid_static_id").widget();
var model = ig$.interactiveGrid("getViews", "grid").model;
var view = ig$.interactiveGrid("getViews", "grid");

//console.log(model);

var aux = 0;
var meta;
var fields;

model.forEach((x)=>{
    //console.log(x);
    //console.log(x[32]);
    //console.log(x[33]);
    if(x[32] > 0 && x[33] != 73 && x[33] != 100){
        meta = model.getRecordMetadata(aux);
        meta.highlight = "civil";
        //console.log(meta);

        fields = meta.fields = {};

        fields.TRIAGEM_IA = {};
        fields.TRIAGEM_IA.highlight = "civil";
        fields.VAZIA = {};
        fields.VAZIA.highlight = "civil";
        fields.NOM_TIPO_ABREVIADO = {};
        fields.NOM_TIPO_ABREVIADO.highlight = "civil";
        fields.TRIAGEM_IA = {};
        fields.TRIAGEM_IA.highlight = "civil";
        //(rest of the columns...)

        aux++;
    }

});

view.view$.grid("refresh");

(请按照下面的代码(在CSS页面内联)):

//IN ROW BACKGROUND-COLOR DON'T FUNCTION...
.a-GV-row.civil{
    color: white;
}

.a-GV-cell.civil{
    background-color: gray!important;
}
英文:

I managed to make it work.

However, I don't have time to comment on the code, but it's not difficult and using the console.log in the variables gives you an idea of what's going on.

I needed to test the value of two pieces of data (in this case column 32 and 33), so APEX's native mode was not working.

(Follow the code below (in Execute JavaScript Code)):

var ig$ = apex.region("grid_static_id").widget();
var model = ig$.interactiveGrid("getViews", "grid").model;
var view = ig$.interactiveGrid("getViews", "grid");

//console.log(model);

var aux = 0;
var meta;
var fields;

model.forEach((x)=>{
    //console.log(x);
    //console.log(x[32]);
    //console.log(x[33]);
    if(x[32] > 0 && x[33] != 73 && x[33] != 100){
        meta = model.getRecordMetadata(aux);
        meta.highlight = "civil";
        //console.log(meta);

        fields = meta.fields = {};

        fields.TRIAGEM_IA = {};
        fields.TRIAGEM_IA.highlight = "civil";
        fields.VAZIA = {};
        fields.VAZIA.highlight = "civil";
        fields.NOM_TIPO_ABREVIADO = {};
        fields.NOM_TIPO_ABREVIADO.highlight = "civil";
        fields.TRIAGEM_IA = {};
        fields.TRIAGEM_IA.highlight = "civil";
        //(rest of the columns...)

        aux++;
    }

});

view.view$.grid("refresh");`

(Follow the code below (in CSS Page inline)):

//IN ROW BACKGROUND-COLOR DON'T FUNCTION...
.a-GV-row.civil{
    color: white;
}

.a-GV-cell.civil{
    background-color: gray!important;
}

huangapple
  • 本文由 发表于 2023年8月9日 03:16:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76862608.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定