Using below, I'm able to change the background color the column in APEX classic report.
#static_id td[headers="TOTAL"]{background: rgb(164, 164, 164) !important;}
How do I change the background color of a row? In this case, I want to change the color of my last row (Totals)
Screenshot
I don't have Apex 5.1 any more; tested this on apex.oracle.com which currently runs Apex 22.1.0.
Classic report query:
select 1 rn, ename, job, sal
from emp
where deptno = 10
union all
select 2 rn, 'Total', null, sum(sal)
from emp
where deptno = 10
order by rn, ename
Create a dynamic action:
Name: da_total_bkg_col
Event: After Refresh
Selection Type: Region
Region: Report 1 (that's the name of region that contains that query)
True condition:
Action: Execute JavaScript code
Code:
$('td[headers="ENAME"]').each(function() {
if ( $(this).text() === 'Total' ) {
$(this).closest('tr').find('td').css({"background-color":"red"});
}
});
Affected elements: type = Region, Region = Report1
Fire on initialization: yes
Run the page; the result looks like this:
Here n=column number, u can simply put this CSS code in inline section
td:nth-child(n)
{
background-color: blue;
}
Related
I have an Interactive Report. The Interactive Report is in a form. There are images and other columns, like the ID, in the Report. How can I get the ID of the selected Row and store it in a Page Item?
This is an example based on the "emp" table in the emp/dept dataset. Functionality: when user clicks on an employee name, the empno of that user is set in page item P44_ITEM.
IR source:
select EMPNO,
ENAME,
JOB,
MGR,
HIREDATE,
SAL,
COMM,
DEPTNO
from EMP
There is a page item P44_ITEM that should be set to the EMPNO when the column ename is clicked in the report.
In the report, set the attribute "Column Formatting > HTML Expression" for the column "ENAME" to value <div class="sel-ename" data-empno="#EMPNO#">#ENAME#</div>. Explanation: wrap a div around the text, and add a class "sel-ename" to the cell and a "data-" attribute containing the empno value for the current row.
Create a dynamic action:
Event: Click
Selection Type: jQuery Selector
jQuery Selector: .sel-ename
Create a true action for the dynamic action
Action: Set Value
Set Type: javascript Expression
this.triggeringElement.dataset['empno']
Affected element P44_ITEM
Save and run.
I have a simple Chart Region: with
Static ID: Chart_Region
Attribute Type: Pie
Chart Serie: Salary Chart
Sql Query: Select Department_id, Sum(Salary) Sum_Sal From Employees Group by Department_Id;
Column Mapping: Label: Department_ID , Value: Sum_Sal and Static ID: Chart_ID
Simply I want to enable the end user to change the Chart Type: Pie to Type: Bar at the runtime (using toggle buttons that I have added).
Any Idea please !.
Thank you in advance.
I found it with Javascript like so:
apex.region('Chart_Region').widget.ojChart({type:'bar'});
and
apex.region('Chart_Region').widget.ojChart({type:'pie'});
available values for type are:
area, bar, boxPlot, bubble, combo, funnel, line, lineWithArea, pie, pyramid, scatter, stock
I have created dynamic list for sub-menu page,now i want to show image for each list entry
A nice feature is to use Apex Font Awesome icons.
Here's an example of a dynamic list query, based on Scott's DEPT table:
select
null lvl,
dname,
'#' target,
null is_current,
case when deptno = 10 then 'fa-thumbs-o-up'
when deptno = 20 then 'fa-thumbs-o-down'
end icon
from dept
order by deptno
When you add the list to the page (as a region), navigate to its "Attributes" and modify template options by setting the "Display icons" property to "For all items".
Once you run the page, you'll see a thumb up icon by department 10 and thumb down for department 20.
List of all available icons is here.
The answer is in Example 1 in the SQL page of the Create List wizard:
Example 1:
SELECT null,
ENAME label,
null target,
'YES' is_current,
'#APP_IMAGES#del.gif' image, -- <-- HERE
'width="20" height="20"' image_attrib,
ENAME image_alt
FROM emp
ORDER BY ename
first use query like below:
select
1 level,
dname label,
'#' target,
null is_current,
'IMAGE'||img_name image
from dept
order by deptno
with this query img_name set as class for each card. after that use this javascript code on page load:
var spns = document.getElementsByTagName("span");
for (var i = 0; i < spns.length; i++) {
if (spns[i].className.includes('-IMAGE')) {
spns[i].style.backgroundImage = "url(#IMAGE_PREFIX#"+spns[i].className.substring(5)+")";
$('.'+spns[i].className.substring(5)).css("background-size", "cover");
}
}
for this background image url should exist images on ords server.
good luck
I'm learning APEX 5
I have a control named X_CONTROL, where I want to populate his content with an SQL query.
To do that, I need the ID primary key from a table, which should be the ID of the row selected on a Select List control named MY_LIST_CONTROL.
MY_LIST_CONTROL has a list of values taken from a column of the table "MyTable", which is not the ID primary key.
I tried to populate X_CONTROL with this SQL
Select ID from MyTable where ColumnName=:MY_LIST_CONTROL
It doesn't work, and should not work because ColumnName is not "unique", like ID is.
So, the question is, how do I recover, with SQL, the ID of the selected row which correspond to the selected value in MY_LIST_CONTROL.
It should be SQL, because APEX 5 demands an SQL query to populate the X_CONTROL.
I have set up a simple example here on apex.oracle.com:
Whenever a Department is selected (item P32_DEPTNO), its Location is copied into the second item (P32_LOC).
This is done by a dynamic action on P32_DEPTNO defined as follows:
Event: Change
Selection Type: Item(s)
Item(s): P32_DEPTNO
TRUE Action:
Action: Set Value
Set Type: SQL Statement
SQL Statement:
select loc
from dept
where deptno = :P32_DEPTNO
Items to Submit: P32_DEPTNO
I would like to customize my column chart API as below
1) When I click on the legend the data set associated with it should return null and show the legend in a disabled color. My code is below.
function drawVisualization() {
// Create and populate the data table.
var chart_div = document.getElementById('visualization2');
var data2 = google.visualization.arrayToDataTable([["Sections","Client Scored",{ role: "style" },"Client Confidence",{ role: "style" },"Average Mark",{ role: "style" },"Average Confidence",{ role: "style" }],["Set 1",90,"opacity: 1",95,"opacity: 0.5",78,"opacity: 1",69,"opacity: 0.5"],["Set 2",65,"opacity: 1",73,"opacity: 0.5",99,"opacity: 1",99,"opacity: 0.5"]]);
var options = {
title:"Understanding",
width:'100%', height:600,seriesType: "bars"
,series:{1: {type: "line",pointSize: 10,lineWidth :0},3: {type: "line",pointSize: 10,lineWidth :0}}
,colors: ['#fafe14','#fafe14','#05afed','#05afed']
,vAxis: {title: "%Score",format: '##', minValue: '1', maxValue: '8'},
hAxis: {title: "",slantedText: true,slantedTextAngle:60, maxTextLines: 5, maxAlternation: 10 },
chartArea: {height: '60%',top:10}
};
var chart = new google.visualization.ColumnChart(chart_div);
chart.draw(data2, options);
}
for this, I tried the hideColumns feature and it worked but the problem is that legend also fades out with the dataset and if I remove second column third column will become second and 4 will become 3 and 5 will become 4.
2) My second question is column 1 and column 3 are lines with line width zero as shown below.
Is there any way to move this to the exact middle of the first bar as shown below
If I'm understanding the first part of your question correctly you're trying to hide a column without removing it from your DataTable.
To have a column in a DataTable not display in a chart drawn from it you can change the column's role to something that doesn't display on the chart.
For example, the annotationText role for a column applies to the annotation column that comes before it, but if there isn't an annotation column before it then the annotationText column will simply be ignored.
So if you want to hide column 2, the following code snippet would do so:
data_table.setColumnProperty(2,'role','annotationText');
And if you want to show the column again you would just change the role back to data
data_table.setColumnProperty(2,'role','data');