How do I select no items with an updateSelectinput in shiny? - shiny

I have a selectizeInput and some action links to make it easier to select certain subgroups. I'd like to have one action link which deselects all values (to make it easier to choose just one item for example -- deselect them all and then the user picks one). The code:
updateSelectizeInput(session, "selectizeList", selected = NULL)
doesn't work, which is by design as the help for updateSelectizeInput (http://shiny.rstudio.com/reference/shiny/latest/updateSelectInput.html) states:
Any arguments with NULL values will be ignored; they will not result
in any changes to the input object on the client.
Given that this is a feature, how can I unselect all values?

I did
updateSelectInput(session, "selectizeList", selected = '')
and it seems to be working for me

Try the following:
updateSelectInput(session, "selectizeList", selected = .)

Related

Navigation button based on a PowerApps dropdown value

I have been trying to set mandatory dropdowns to be selected in order to go to the next screen.
Next screen is called End
Dropdown is called type_4
This is the code that I used but it doesn't seem to go through:
If(
IsBlank(type_4.Selected.Value),
Notify("Fill all the fields to continue", NotificationType.Error),
Navigate(End,ScreenTransition.Cover) )
This issue is specific to dropdown inputs. If it was a text field all I do is replacing Selected.Value by Text and it works fine.
Dropdowns are my only problem so far.
EDIT: The default value of the dropdowns is Select your answer (first choice of the dropdown).
If the default option for your dropdown is 'Select your answer', then you can use an expression similar to the one below:
If(
type_4.Selected.Value = "Select your answer",
Notify("Fill all the fields to continue", NotificationType.Error),
Navigate(End,ScreenTransition.Cover) )

Oracle Apex Dynamic action not working for form items

I have a form with items P1_APP and P1_USER.
P.S. P1_USER is select list.
Display John
Return 1
Display Andy
Return 2
I need to disable when user selects John.
When P1_USER = 'John', P1_APP should get disabled which is a multi select list.
I created dynamic action on P1_APP, True Action= Disable,Affected element P1_APP
Client condition : Item =Value
Item= P1_USER
Value= John
However this is not working.
I have used similar logic to disable interactive grid items and was able to do so. Why is this not working for form?
EDIT: In Value now i am putting 1 which is return value for John.
However when i select John. It disables P1_App upon clicking. But remains disabled even when i choose Andy.
This works for me using the following configuration.
Create form and report on EMP - everyone has access to that sample data, it is a good idea to post questions based on that.
In the form P3_DEPTNO is a select list with source
SELECT d.dname, d.deptno FROM dept d
Add a page item to my form P3_APP. This is a select list with "Allow multi selection" enabled. Select list has 2 static values.
Create a dynamic action on change of P3_DEPTNO.
Client side condition: Item = Value
Item: P3_DEPTNO
Value: 30 (note that this is the return value for SALES, not display value)
add true action of "Disable", affected item P3_APP
Click true action and select "Create Opposite Action". Save.
When I run this it work. Selecting SALES in the select list disables the item P3_APP and selecting something else enables it.

How to sort in Oracle Apex 19.1 Interactive Grid

I'm using Oracle Apex 19.1 on a 18.c platform.
I have a page with two regions: 1) Interactive Grid and 2) Interactive Report
I use the Interactive Grid to display a list of Producer names. When the user selects one of the names, the Interactive Report refreshes and displays the events assigned to that Producer. I use a Dynamic Action to update the Interactive Report.
This all works fine, except for the list in the Interactive Grid. It seems to display names in order by the table's PRIM_KEY and I want to sort the Interactive Grid by last name. The Source Code for the IG doesn't accept an Order By clause.
Select ac.first_name || ' ' || ac.last_name PRODUCER
From aff_contact ac, aff_contact_role acr
Where ac.prim_key = acr.contact_fkey
And acr.role = 'Producer'
;
The problem is, the column names in the IG toolbar's Actions / Data / Sort never populate. I wondered if the dual column in the Select statement was the problem, so I tested it with a simpler query for the Source:
Select last_name
From aff_contact
;
That still didn't produce columns to select for the sort. I receive a screen like the one below:
The Column select field has nothing to pull down. That holds true for both the original and the simplified query.
How can I get the IG to sort based on the LAST_NAME field? Is there another way to achieve this goal?
Thanks for looking at this.
After further checking, it seems that a VARCHAR2 column with a width <= 99 is selectable as a Sort or Control Break. A VARCHAR2 column with a width >= 100 is NOT selectable for Sort or Control Break in an interactive grid.
To identify the fields in the report Source I used the syntax:
cast( first_name as varchar2(32)) "FIRST_NAME",
cast( last_name as varchar2(32)) "LAST_NAME"
to avoid the default column width.
To sort by column:
01. Click the Actions menu, select Data, then Sort. The Sort dialog appears.
02. In the Sort dialog: Select a column, the sort direction (Ascending or Descending), and the null sorting behavior (Default, Nulls Always Last, or Nulls Always First).
a. Column - Select a column.
b. Direction - Select Descending or Ascending.
c. Nulls - Select First or Last.
03. To add another sort rule, click the Add button (+).
04. Click Save.
05. Click Report
06. Click Save
The interactive grid reloads.
Note:To ensure column sorting active. To ensure that you are login developer mode, otherwise it is not show other user

Oracle Apex: Auto select if shuttle list contains only a single item

I have a shuttle list that, depending on the selection of a previous form, may have between one and seven items. Is there any way for me to automatically move the entry to the right hand pane if there is only a single selection, just for the sake of long term optimization and user friendliness?
You can add a default Value to your shuttle item
SELECT YOUR_COLUMN_ID
FROM T0000_YOUR_TABLE
WHERE FILTER_COLUMN_ID = :P_FILTER_ITEM_PREV_FORM
GROUP BY YOUR_COLUMN_ID
HAVING COUNT(*) = 1
If there are more than 1 entries for your filter item the statement will return nothing, if there is exactly 1 entry the entry will be returned and set for your shuttle item
I like sim0n's answer. But here's another that uses JavaScript (you can choose which is best for your use case).
Create a Dynamic Action. Set Name to Page loaded and Event to Page Load.
Select the Action created by default. Set Action to Execute JavaScript Code, then enter the following code in Code.
var itemId = 'P1_ITEM_NAME';
var $opts = $('#' + itemId + ' select:eq(0) > option');
if ($opts.length === 1) {
$s(itemId, $opts.val());
}
Don't forget to change the name of the item to match the one on your page.
When the page loads, the JavaScript will check to see how many options are in the select element on the left. If there's just one, it will set the value of the item using the value to the value of the single option.

How to only display 'Edit' link on certain rows on apex interactive grid?

I have an interactive report apex5.0 which contains several fields.
Would like to disable 'edit' pencil option link where payment_date & code is populated.
Link is to be enabled only where payment_date & code is null.
Disable the edit button for a particular row, based on a specific value in its column.
For ex. If a grid has 3 columns A,B,C and if B contains "Apple", and '01-jan-17', the edit button for that row must be disabled.
What are the different options to do this kind of functionality in apex5.0, enable & disable "EDIT" based on certain criteria?
You could also add a case statement to your report's query.
E.g.
(Case when [some logic] then
--display link
'<img src="#IMAGE_PREFIX#menu/pencil16x16.gif" alt="" />'
End) as col_link
The above example will only display a link if the case statement is met. The link will point to page 47 and we will pass the query's Id column to page 47's item P47_ID
In order to treat this new column as a link you must change the "display as text" property to "standard report column"; you can achieve this when editing the report attributes.
One way is to use JavaScript on page load:
Let's asume that first column is with ID and used to show edit link. Second column is your product name like Apple. Just disable click on this element(cell with ID) or change link, img etc.
var table = $(".a-IRR-table tbody");
table.find('tr').each(function (i, el) {
var $tds = $(this).find('td'),
productId = $tds.eq(0).text(), //first column with ID and edit link
product = $tds.eq(1).text(), //second column
Quantity = $tds.eq(2).text(); //third column
if (product == 'Apple'){
$tds.eq(0).click(false);
$tds.eq(0).replaceWith('');
}
});
Thanks to this answer for JavaScript: Loop Through Each HTML Table Column and Get the Data using jQuery
EDIT:
To hide value based on your Query use CASE. For example:
SELECT
CASE
WHEN B = 'Apple' THEN
'<img src="#IMAGE_PREFIX#edit.gif" alt="">'
ELSE ''
END edit_link,
A,B,C
FROM TABLE_NAME
Click on column edit_link and make it of type Link
Choose your target to edit page
For link text select #EDIT_LINK#
Escape special characters must be set to NO
On Report Atributes set **Link Column** to **Exclude Link Column** (you have custom link column so don't display original link)
*Check your online workspace, page 3*