I have an LOV in my HTML page that I created with APEX_ITEM.SELECT_LIST_FROM_LOV
Should I also create a Page Item for it?
I mean I am a bit confused because this item has no name as they got if I 'd create an LOV as PAGE ITEM.
How should I get the selected value to insert it for example, into apex_collections?
Thanks in advance
You can get the value of an item created using the APEX_ITEM package by looking at the PL/SQL array apex_application.g_fNN where "NN" is the number you used as the first parameter to the APEX_ITEM function.
For example, if you used APEX_ITEM like this:
apex_item.select_list_from_lov(42, 'MY_LOV')
then you can get the values like this:
for i in 1..apex_application.g_f42.count loop
l_value := apex_application.g_f42(i);
end loop;
(If you had used APEX_ITEM in a multi-row report then there will be more than 1 element in the array.)
Related
The same question once again but with (I hope) better explanation:
I created the most simple case:
An Interactive Grid IG with data source EMP ( table with 14 records contains Ename, Job, HireDate, Salary etc. etc.)
Text field P7_ENAME
After running it looks like below:
What I would like to do is to copy Ename from selected record of IG to P7_ENAME field .
I found several tutorials (text and video) how to do it. Most of them suggest to create dynamic action SelectionChange on IG and when TRUE add a JavaScript code something like below:
var v_ename;
model = this.data.model;
v_ename = model.getValue( this.data.selectedRecords[0], "Ename");
apex.item( "P7_ENAME" ).setValue (v_ename);
and the second step is to create another action: Refresh.
So finally I have a dynamic action with two steps : the first one is a Java script code and the second refresh function on my P7_ENAME field.
Sounds simple and it is simple to repeat/implement. A guy (I suppose) from India published a video on YouTube (https://www.youtube.com/watch?v=XuFz885Yndw) which I followed and in his case it works good. In my case it simple does not work - field P7ENAME is always empty, no errors appears. Any idea why ? Any hints, suggestion ?
thanks for any help
K.
The best way to debug and achieve what you are trying to do is as follows:
create the Dynamic action with the following setup:
-when -> selection change[interactive grid],
-selection type -> region, region -> your IG region,
-client side condition -> javascript expression: ```this.data.selectedRecords[0] != undefined```
First action of the true of the DA with the type: execute javascript code and fire on initialization is turned on, code: console.log(this.data.selectedRecords);
Run your page, and check the browser console. You should see an array of columns when you select a record from that IG as follows:
Find in that array, which sort number of the array contains the data that you want to use for the page item. Let's say I want the 3rd element which is "2694" then I should change my dynamic action's execute javascript code to:
var value = this.data.selectedRecords[0][2];
apex.item( "P7_ENAME" ).setValue (value);
The last thing I should do is add another true action (and the refresh action at the end) to the same dynamic action with type 'SET VALUE' and 'PLSQL EXPRESSION' as type, put :P7_ENAME in the expression, items to submit P7_ENAME and affected element: item / P7_ENAME as follows:
I am using APEX 21.1. I have a checkbox group whose list of values is retrieved using a query...
select disease, id from history;
The query returns many checkboxes. I have another textarea item. I need to get the display value for any checkbox whenever it's checked and set item HISTORY to that value. How to do so?
Describing a how-to would be so much easier if you had provided some example page item names and example data. So, lets call your checkbox group P10_CHECKBOX and your textarea P10_TEXT.
Usually, your checkbox group will save the item ids as a colon seperated list, like this: 3:4:5
To display the corresponding display values, make a dynamic action on change on your item P10_CHECKBOX.
Then, use an action of type Execute PL/SQL Code to fetch the display values of your items.
The code could look like this:
select listagg(disease,chr(10)) within group (order by disease) into :P10_TEXT
from history h
join table(apex_string.split_numbers(:P10_CHECKBOX,':')) t on (h.id = t.column_value);
apex_string.split_numbers will convert your colon list into an actual "table" with the column column_value you can use in the join clause. listagg will do the actual concatenation and will work up to a couple thousand characters. chr(10) is an ordinary line break and will have your items be shown line by line, but any other seperator will do.
Last step is to set up P10_CHECKBOX in your Items to submit and P10_TEXT in your Items to return.
Now, whenever you click a checkbox, the textarea will be updated immediately.
I am working with Apex_Item_Text .. i am using the below query to display the text area in apex as null initially.
select distinct a.GUID, a.CREATED_BY, a.created_date, apex_item.text(null)
Delete from
NON_DYNAMIC_USER_GROUP_MEMBERS a,
NON_DYNAMIC_USER_GROUPS b
where a.DYNAMIC_GROUP_ID in
(select DYNAMIC_GROUP_ID from NON_DYNAMIC_USER_GROUPS
where instr(','||DYNAMIC_GROUP_ID||',' , ','||:P153_ID_HIDDEN||',') > 0) ;`
In Apex application once the text area filled by user as Delete/Add, it has to update in table when submit button pressed, i don't know how to proceed further on this.
Thanks
You need to pass in a number into the apex_item.text function. By passing a number APEX will automatically create an array that will store the values of those columns.
This can be referenced in your delete statement with: APEX_APPLICATION.G_FXX(i) where XX is the number you pass into the apex_item.text function and i is the index of the item.
Without passing a number into the apex_item.text function I would have no idea how to reference that field
See oracle documentation for more information about apex_item.text: https://docs.oracle.com/cd/E14373_01/apirefs.32/e13369/apex_item.htm#AEAPI211
This is a VERY basic question. Sorry for not providing any code I have NO IDEA how to even start tackling the problem
I have lets say two fields... One is a date selector field and the other a regular text field. What I want is when I select a date (or type a date), the value comes in the second field... Just that...
I'm on APEX 5.1.4
Since you have stated that the second item is a text field, you could do this with the help of a dynamic action that sets the value of the second item when there is a change in the value of the first item ( date field).
The following would be the steps, if you are using component view:
Create Dynamic Action
When
Event : Change
Selection : Item(s)
Item : First Page Item
Condition : is not null
True Action
Action : Set Value
Fire on Page Load: No
Set Type: You can choose how you want to set the value of the second item on the page.
If you have the flexibility to change the second item to be a select list and you have a list of values that goes with a date, you could do this much simpler, with a Cascading LOV
On Second Item's - Under List of Values section
Cascading LOV Parent Item(s) : First Item
Page Items to Submit: First Item
List of Values definition: Here you can define the query.
Hope this helps.
There are a few different ways to do this, probably the easiest way is as follows.
Assume your two items are P1_ITEM1 and P1_ITEM2.
Create a dynamic action which fires on change of item P1_ITEM1.
The true action of this should be action:set value, set type:PL/SQL Expression, item::P1_ITEM2, items to submit P1_ITEM1.
I've searched a lot about the way of getting inedx of selected item of combobox inside datagridview but i have not found it !!
I can get the value of selected item by :
dataGridView1[j,i]->FormattedValue
But i can't get the index !
i've tried to cast DataGridView to DataGridViewComboBoxCell to use (SelectedIndex) property
DataGridViewComboBoxCell ^ t = dynamic_cast<DataGridViewComboBoxCell ^>(dataGridView1[j,i])
but there isn't any propery shown for "t" !
The DataGridViewComboBoxCell does not track the selected index.
You could play with its editing control, DataGridViewComboBoxEditingControl, to get the inner ComboBox, but it will be clumsy.
The simplest thing you can do is to lookup via IndexOf the cell Value in the collection of all possible values you use to initialize the DataGridViewComboBoxColumn.