In Oracle Apex how do you create a Select List with sub-lists? - oracle-apex

I want to create a Select List where some values can have a list of sub-values, like this:][1

You can't (at least, as far as I can tell).
What you could do, is to create two select list items (or any number of them) so that they represent a cascade, which means that the 1st item is "master". The 2nd item contains its own query which - in its where clause - references the 1st item which is also to be set as the parent item for the 2nd item.
And so forth, for all cascading items.

Related

Select List item default value

I have Select List item based on List of Values (Shared Components). As default value is null and there is problem, I have another Select List item based on SQL Query which one uses value of first Select List. Cascading List of Values not helping. How I can set first Select List value as first value by default? Clientside value is not null, but serverside is. Exactly I can change Source of first Select List item, but I don't want use the same query which one I use in List of Values from Shared Component. Page submit or item submit in Dynamic Actions is slow and user see that. Are there any other solutions?
P.S: For example first Select List displays Countries, second Select List displays cities. In my case when first Select List is null, second Select List displays all cities from all contries, I don't want this, I want to make first Select List without null value and second Select List with values (cities) by value from first Select List (country, not null).
In one of application page it works like I need, but I can't understand how, and I can't find the difference in code. In page where it works session page displays item value (Page Items, Session State), in another isn't.
If you set "Display NULL value" to "No", it will show the first value of the select list

Efficiently retrieve from and add to ManyToManyField

I have two models, let's say Container and Item. Container has a ManyToMany field to associate Containers to Items. I want to add an Item to a Container and then list all of the Items in this container. However, I've noticed that Django queries for each item before it adds it, therefore I end up with three queries, one to get all of the Items, one to check if the Item I want to add is there, and another to add the Item. Is there a way to eliminate this superfluous checking?
I've tried replacing the item_set entirely using the set command but it still adds the extra check for duplicates.
# Select all items in item_set
existing = container.item_set.all()
# Select item in item_set (even though we know) and insert item into set
container.item_set.add(new_item)
In brief: I would like to end up with a new item added to the set and all the old items from the set in two queries
There is no need to check if the relationship exists before adding a new item to the many-to-many relationships. Adding an item to an already existing relationship will not result a new row being added. You can refer to this answer for details.
In other words, you can safely add the item without checking first and then perform a retrieval:
container.item_set.add(new_item)
items = container.item_set.all()

Sales list force change of column in lines

I'm using the page below a POS sales list. Here the user can use the barcode pistol and pass the article and the code is translated into the item no.
The problem is when they use the pistol and end to pick a item and want to pass to next one the line go automatically to the first column (Item type) and my goal was to force to go into the second column (Item no), because the Item type is by default the type "product".
Only change the order of columns of Item no to Item product is not enough in this case.
Since ACTIVATE is not supported for controls in RTC.
Not many good options here.
Try using QuickEntry Property. Set it to false for all controls on subpage except No..
Create custom page with as less fields as possible, use it as buffer to scan all items and create sales lines upon closing of this new page. You can implement desired behavior on this page and keep original page almost unmodified
Create add-in that will intercept scanner output somehow.

Grabbing values from select list

i have a select list displaying all the names from the table X
i want to add id of that corresponding name in to another table naming Y.
HOW TO GRAB VALUE FROM SELECT LIST AND STORE IT IN TO DATABASE TABLE???
A list of values doesn't depend on anything; you can write any query you want (which includes your table X), as long as it returns two values: display and return ones. For example:
select name display_value,
id return_value
from table_x
where <some condition, if there's any>
order by name
If you create a form page and make its source table Y, choose which one of the columns should contain an ID returned by the Select List item and put the above query into its LoV property.
Run the page;
choose a value from the Select List;
Submit
Should be OK.
You need to create an Apex process to perform your desired action, like store the value in your database.
Once your user selects a value from your LOV, usually you'll want to submit the page, which you would tell to run that process.
Alternately, you could create a Dynamic Action on the LOV that runs a PL/SQL process to do your database change.
You may have gotten an answer by now but I thought I'd take a swing at it. I'm trying to get my reputation over the next threshold. :-)

Can I remove items from a ComboBox without changing the index of other items?

I have a CComboBox control with several items and I need to remove some of them, but the indexes of the remaining items should be preserved.
When the combo box is populated, the item data is set like so:
index = mycombo.AddString(temp);
mycombo.SetItemData(index, static_cast<DWORD>(count));
where count is a loop counter, and should be equal to index
Now I want to remove some of the items later, but I need the index of each remaining item to stay the same. Is CComboBox::DeleteString(UINT nIndex) what I should use? Its documentation says:
All items following nIndex now move down one position. For example, if a combo box contains two items, deleting the first item will cause the remaining item to now be in the first position. nIndex=0 for the item in the first position.
Is that talking about the physical location in the drop-down menu, or the index value associated with the item?
Is there another function that does what I need? Another solution altogether?
Is that talking about the physical location in the drop-down menu, or the index value associated with the item?
For a ComboBox (as well as ListBox, List Control, and probably many other such things) the location of an item on the control is directly tied to its index. The index is the location. Really, just think of it as if ComboBox was implemented internally using a simple std::vector. You can't remove an entry from a vector without affecting the indexes of all subsequent entries, and it is just the same with these controls.
However, the Item Data of an entry in a ComboBox (and other such controls) sticks with that entry no matter what index it is reassigned to.
Say you created two entries: the first at index 0 has text="A" and ItemData=0; while the second at index 1 has text="B" and ItemData=1. If you then remove that first entry, the second entry will shift down the claim the index and its ItemData will travel along. So you would be left with a single entry at index 0 having text="B" and ItemData=1.
In a combobox you have items which have a string and an integer value associated. Normally, you just see the string. Those items are referenced by an index, which just represents the location of each item in the list. If you remove an item, all the items below it are "relocated", so the index changes. The same happens in you insert an element anywhere between two items, or at the beginning.
The index always goes from 0 to (number_of_items-1), and there's nothing you can do about it.
That said, the item data always stays with the item, and it's this what you should look at when looking for a specific item. Not its index, and neither its string. Look at the item data. The index can change if you add, remove or resort the items. The strings will change if you localize the software. So use the data to properly identify each element.
You can take a look at http://www.flounder.com/combobox.htm, where you can find a better explanation, with some examples and code to do work with comboboxes more easily.
Adding or removing items does not change the number you passed to SetItemData(). GetItemData() returns the same number. You however need to pass the index of the item to DeleteString(). When lower numbered items were deleted before then the index will no longer match GetItemData(). If you lost track of the index of a specific item you want to delete then you need to iterate the items to find it back.