Oracle Apex Interactive Grid Cell Format - oracle-apex

Basic question please, I have an IG.
Trying to format a column using the following:
SELECT
CASE
WHEN my_number <= 3 THEN 'u-color-7-bg'
WHEN my_number > 3 THEN 'u-color-8-bg'
END some_color
FROM my_table
I'm modifying the resulting column 'some_color' to be an HTML Expression type.
On its HTML Expression part I have:
< span style="color: &SOME_COLOR.">&MY_NUMBER.< /span>
But it doesn't work, no format is getting applied whatsoever.
Can anybody give me a hand please?

u-color-xx are CSS classes not actual colors. It should work if you try <span class="&SOME_COLOR.">&MY_NUMBER.</span> instead.
Alternatively you can use CSS-Variables defined by APEX in newer versions like this: <span style="background: var(--u-color-35)">&MY_NUMBER.</span>

Related

Convert HTML Table to plain Text in Power BI

I am a beginner in power BI. I have to create a report with share point data. I have imported the data into dataset. However, some columns have text with html table tags or style like below -
<div class="ExternalClass5DA0D04953B047459697675F266FEABF">
<p>​</p>
<table width="395" border="0" cellspacing="0" cellpadding="0" style="width:296pt;">
<tbody>
<tr height="115" style="height:86.4pt;">
<td width="395" height="115" class="xl64" style="width:296pt;height:86.4pt;">
I am working on issue. I shall update the progress. <br>
</td>
</tr>
</tbody>
</table>
<p><br></p>
</div>
But I would like to show the plain text only which is "I am working on issue. I shall update the progress."
From this community thread, you can find a handy function for stripping all the HTML tags:
Here's the core logic (ignoring the documentation metadata for readability):
let func = (HTML) =>
let
Check = if Value.Is(Value.FromText(HTML), type text) then HTML else "",
Source = Text.From(Check),
SplitAny = Text.SplitAny(Source,"<>"),
ListAlternate = List.Alternate(SplitAny,1,1,1),
ListSelect = List.Select(ListAlternate, each _<>""),
TextCombine = Text.Combine(ListSelect, "")
in
TextCombine
in
func
Having this handy bit of code, create a new blank query and paste the above code into the advanced editor and give it a name, say, TextFromHTML.
Once you have that function defined, you can use it in any of your queries. For example, here's what a step to transform the column ColWithHTML might look like:
Table.TransformColumns(#"Prior Step", {{"ColWithHTML", each TextFromHTML(_), type text}})
You can create a new column with below formula as show below
if [HMTLField] = null then null else Html.Table([HMTLField] , {{"text",":root"}})
Then click on the button on right top of the field to convert this field as text by expanding it.

//*[#id="gwt-uid-2423"] is getting changed every rime in selenium python2.7 chrome

HTML Code is ..
<div class="N1LCMI-ib-e" role="option" id="gwt-uid-2423" style="user-select: none;">Hotel ID</div>
There is one button when i click on it there are some categories to select Only one category can be selected in one time. So Id in xpath is getting changed every time when i am using Xpath of that category. below is code which i am using to select that category.
driver.find_element_by_xpath('//*[#id="gwt-uid-2423"]').click() #select Hotel ID
so only 2423 part is getting changed every time.
is there any other way to go for it. pls help....
As you mentioned that the 2423 part is getting changed every time for the id attribute, so we can create a unique css_selector or xpath as follows:
css_selector :
driver.find_element_by_css_selector("div[class='N1LCMI-ib-e'][id^='gwt-uid-']").click()
xpath :
driver.find_element_by_xpath("//div[#class='N1LCMI-ib-e'][starts-with(#id, 'gwt-uid-')]").click()
You can find the element by contained text using an XPath.
//div[.='Hotel ID']

Change <td> to <th> in first row of a HTML table server side using Cold Fusion

I am sending a HTML string to the Cold Fusion (9) server. The string contains a HTML table with multiple rows. Since the table doesn't have a head I need to change the <td>s of the first row into <th>s.
For your information:
The code to change is a paste code coming from MS Word. The code gets sent to the server to check if there are any tables in it. If yes, there is an option dialog shown to the user where he can descide how the table will be formatted (striped, hovers and so on).
In my opinion the best way to do that would be ReReplace(). But I can't figure what the right regex can be.
Any suggestions on that will be much appreciated.
The code looks like:
<table class="table">
<tbody>
<tr><td>Head 1</td><td>Head 2</td><td>Head 3</td></tr>
<tr><td>Content 1 Row 1</td><td>Content 2 Row 1</td><td>Content 3 Row 1</td></tr>
<tr><td>Content 1 Row 2</td><td>Content 2 Row 2</td><td>Content 3 Row 2</td></tr>
</tbody>
</table>
And should look like:
<table class="table">
<tbody>
<tr><th>Head 1</th><th>Head 2</th><th>Head 3</th></tr>
<tr><td>Content 1 Row 1</td><td>Content 2 Row 1</td><td>Content 3 Row 1</td></tr>
<tr><td>Content 1 Row 2</td><td>Content 2 Row 2</td><td>Content 3 Row 2</td></tr>
</tbody>
</table>
Thanks in advance.
Obligatory warning: maybe a parser or as #npinti suggested changing the output in the first place is a far better way to go.
That being said, you could use a lazy quantifier (expensive!) between the <td> tags and feed the function chunks of <table> parts and substitute it with <th>\2</th> (see the regex 101 demo for an example).
(<td>(.*?)<\/td>)
Hint: This does not take additional attributes into account (e.g. class="test123").

How do I display a new line within column data in an Apex Interactive Report

I'm using Apex 4.2 and Oracle 11.g
I have a column called "Transaction Detail" that I display in an interactive report. The report column's Display Text As selection is set to "Standard Report Column".
The report column is selected from a varchar2 table column called transaction_detail. I'm just building the table as well. The transaction_detail table column is populated from a Procedure with the following code:
Insert into mail_log (transaction_type, transaction_detail)
Values ('FTP Transaction',
'Filename=' || p_image_filename ||
'<br/>' || 'Event Description=' || l_event_description);
The procedure code can be easily changed.
The report just displays:
Filename=myfile.jpg<br/>Event Description=my description
I've tried using CHR(13) in the procedure instead of the html characters and then tried to replace the CHR(13) in apex with html characters. Instead of simply selecting the column:
, transaction_detail
I tried:
, REPLACE(transaction_detail, CHR(13), '<br/>')
but I couldn't get past an Apex error: ORA-12899: value too large for column "APEX_040200"."WWV_FLOW_WORKSHEET_COLUMNS"."DB_COLUMN_NAME" (actual: 49, maximum: 30)
Shouldn't Apex be able to interpret the as a new line if the column is a Standard Report Column?
Thanks for looking at this.
This was answered on the OTN forum by Jorge (jrimblas) and others. The link to that discussion is above. Short summary, In the stored procedure I got rid of the '<br/>' and replaced it with CHR(13). Then, in the Apex interactive report, I did NOT need to change the column to "Standard Report Column". I placed the following in the "HTML expression" for the column.
<div style="width:240px">
<pre style="font-family:Arial; font-size:12px; white-space:pre-wrap">#TRANSACTION_DETAIL#</pre>
</div>

Make expression match optional value if possible

Consider the following text that might be part of an HTTP response from jMeter:
<menu id="Alpha" name="alpha">
<option value="a">A</option>
<option value="b">B</option>
<option value="c" selected="selected">C</option>
</menu>
<menu id="Bravo" name="bravo">
<option value="d">D</option>
<option value="e">E</option>
</menu>
I'm trying to extract the ID of each menu, as well as the selected option's value if there is an option selected. If there is no option selected, then by default, the first option's value should be matched. For example, in this example, I want the following to be matched:
"Alpha" "c"
"Bravo" "d"
So far, I have written the following:
<select id="Form:parameterList:([^"]+?)".*?>.*?(?:<option value="([^"]*?)".*?(?:selected="selected")?>)?.*?</select>
The problem with this is that only the first option's value is ever matched, and the selected option is never matched. That is, I want to prioritize matching the optional pattern.
Thanks,
Victor
Consider how maintainable your script will be using that complex regex.
You can achieve the result you desire using xpath extractors, conditional/loop controllers and or post-processors...
First get a list of all ids:
//menu/#id
You can get a list of ids containing an option with attribute selected = 'selected' with something similar to:
//menu/#id[/option[#selected='selected']]
Iterate through the first list (in a beanshell processor or loop controller, for instance). Where an id appears in the second list, extract the selected value with:
//menu[#id='xxxx']/option[#selected='selected']/#value /*substitue xxxx with appropriate id*/
Where the id does not have a 'selected' value, extract the default value:
//menu/[#id='xxxx']/option[1]/#value /*substitue xxxx with appropriate id*/
(sorry if my xpath aren't completely accurate, I have written this from memory alone, but hopefully the breadcrumbs are there to follow)