Add choices to a selectInput - r

I have a selectInput with all the possible choices displayed. I want to implement it such that if a user types something in the box and hits enter, that will also be added as a choice.
observeEvent(input$mykeypress, {
if(input$mykeypress == 13){
print(input$selectBox)
}
I tried the above code to see if my input changed, but it seems that no matter what extra stuff I type in the selectbox, none of it is recognized.
Anyone have ideas as to have I can recognize anything extra that the user types?
Edit: One other idea I am considering is creating a textInput, and prepopulating it with all the values that I used in my selectbox. Is something like that possible?

I ended up figuring it out, because the selectizeInput just wraps around selectize.js, in your selectizeInput you can use the argument: options = list(create = TRUE), and the user can add words easily.

Related

R Shiny Refresh App Keep Same Tab

I would like to have the Shiny app remember which tab was selected at the time of a session$reload() (refreshing the page) to clear all inputs except the value of the current tab selected in a navbarPage().
The only idea that comes to mind, though I don't know how I could implement this, would be to assign a global variable tabIndicator as the value of the current tab selected (how do you get this value?), then on refresh, rm() all variables in global environment except tabIndicator, and set selected = tabIndicator in navbarPage().
How can I accomplish this?
You have two options, both are beyond the basics of shiny.
You could use cookies. Every time a new tab is entered, send a message to javascript and set a cookie. When the app initializes, check for the presence of the cookie, and if it's set then read its value and change to the appropriate tab
Use the shinyStore package, which gives you the ability of leveraging HTML5's local storage (but this won't work on older browsers because HTML5 is relatively new)
I don't have time to provide full code right now, but hopefully this helps
It's doable, I think, but tricky. The issue is that session$reload() is equivalent to hitting the refresh button in the browser, so you're creating a new session, and losing all of the context. I guess you could use cookies somehow to do it, but I'd recommend using an actionButton that resets all of your inputs using updateWhatever, instead of actually doing the session$reload().
I was able to figure it out using a global variable.
I put this code at the top of my app (before ui and server)
# Clear global environment except 'currentTab'
rm(list=setdiff(ls(), 'currentTab'))
# If current tab exists, restore to that tab. Otherwise, start at home screen
if(!exists('currentTab')){
currentTab <- 'HOMEPAGE'
}
And this code at the bottom of my server
# Current tab
observe({
currentTab <<- input$navbar
})
Works like a charm. Thanks to all for the help.

Telerik RadGrid: Show column only in edit mode?

I'd like to "hide" one column in my RadGrid and only have it show when I'm in edit mode. I tried just moving it into the edit item template, but that didn't work at all.
Any suggestions would be deeply appreciated!
Thank you!
Oy...
"Paul's Third Law of Asking For Help
You will discover the obscure answer 5 minutes after giving up and asking for advice."
Turns out you set the column to "Display=False" but only if you are in popup or edit form mode, not inline.
Hope it helps someone else.
Even though you did answer this yourself I thought I'd write an answer to clarify some things.
You can set the default value of the EditColumn to be false, even in InPlace edit. However it makes it a lot more difficult to save edited data as the InPlace edit (for simplicity) requires the EditColumn to display the save or cancel items.
That being said, you can do it - however you need to use explicit CommandNames on the items:
Say you want to Update a row with the new values you have inserted in the InPlace edit. Then the confirm button's CommandName would HAVE to be "Update" to be picked up correctly.
All of this being said, it would be a lot simpler for you to keep the EditColumn intact even when in InPlace (editmode).
Or you could specify the EditTemplate for one column to widen the column, add the two buttons necessary to perform Update and Cancel as well as hiding the EditColumn so that multiple InPlaceEdits can't be performed at the same time. :)
I hope this helps someone, as I was stuck in a similar situation myself when I had to incorporate both InPlace and EditForms EditModes on a single RadGrid and knowing the above information made a WORLD of difference.
You can try this:
var agtype = $telerik.$(atCell).text().trim();
if(agtype == ""Guaranty""){{
var masterTableView = sender.get_masterTableView();
var columnIndex = masterTableView.getColumnByUniqueName(""Amount"").get_element().cellIndex;
masterTableView.showColumn(columnIndex);
}}

check box in asp.net webform

I need help in check box my problem that when i select any one it gave me message
about my selection but when choose two of check box gave me the last choose of them why and what is the fix please
What is happening is that your Append status is wrong. Instead of appending, you are overwriting the current value. Hence when you choose say two answers, the first is overwritten by the second.
I think the problem is with the syntax of your Append status. Instead of:
Append(Label5.Text =("New Text"));
It should be something like:
Append(Label5.Text).Append("Your new text");
See:
https://msdn.microsoft.com/en-us/library/b4sc8ca8(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1

Disable a form field in LotusScript or using Input Enabled formula

Using Domino Designer 8.5. If I have a form with a radio button field, is it possible to disable that field in LotusScript, possibly in the Postopen even of the form?
The only way I can, so far, see of achieving this is by using the Input Enabled formula of the field itself, but I am struggling to understand when this is triggered... if I try to put a #StatusBar or #Prompt formula call in there as well then there is never any notification of Input Enabled being triggered.
If Input Enabled is the way to achieve this, not LotusScript, then is there a way I can have a) a formula that sets the Input Enabled condition plus b) a way of getting some visual output, either to the Status Bar or a Message Box, to either just indicate the formula has been triggered or - even better - to let me know the value of some variable I'd like to check?
The Input Enabled Formula is triggered on every refresh of the document (F9, Save, NotesUIDocument.Refresh, etc.), it can not contain any code "interacting" with the user.
But you could do something like this:
Create a Field "InputEnabled"
The best way to have a "controlling" field is to make it "Computed for Display". That way it is not stored in the document. As a formula you simply enter #ThisValue, then it does not change its value by itself and can be set using LotusScript. If you want to have an "initial" value, then the formula would be: #If( #ThisValue = "" ; "YES" ; #ThisValue )
In the "Input enabled" Formula of your other field write the code:
InputEnabled = "YES"
Fill the "InputEnabled"- Field using a LotusScript (NotesDocument.ReplaceItemValue( "InputInabled", "YES" ), or using a Formula directly in the field.
Like that you can easily "see" what the conditions are (in the field InputEnabled) and change it using formula or script.
Old school way to Disabling the radio button field:
You will have to use the **Hide paragraph if formula is true". Define a field: MyButEnabled accorting to which you enable (show) or disable (hide) the field. for UI convience display a complementary line that only display the value of your radio button (you can also use a computed radio button but it's not very pretty).
In the post open set the appropriated value for the field MyButEnabled. Dont forget to call uidoc.RefreshHideFormulas method.
The notes input enabled way: (see also: http://www-01.ibm.com/support/docview.wss?uid=swg21173862)
the notes input enabled formula is (for example)
#if(MyButEnabled="Y" ; 1 ; 0)
When you form is openned, the formula is computed, if the result is 0 the field won't be editable, 1 will allow field to be edited.
If you change the value of MyButEnabled, then you need to make a UIdocument.refresh in order to change to be reflected in the UI.

Checboxes input helper PodsCms

i created a multiple checkboxes input helper adapting the code from this http://podscms.org/packages/checkboxradiobutton-yourvalues/
I modified it so that people don't have to hardcode values into the helper; instead values are taken from the column comment field (having a data field for columns would be appreciated in pods 2.0!)
Here is the helper: http://pastebin.com/w0UxDmnG
I encountered two problems, the first of which i already solved:
At thw beginning i enclosed the whole code in a function, to keep clean the namespace (isn'i it the right thing to do?). but i noticed that i do this, when i have two columns with this helper many strange things happen: the second column is blank, doesn't show checkboxes. After the second column with this helper no more columns are shown.Rich editor commands on all textareas don't appear and textareas themselves are non editable.
I suppose is an effect wrapping the code in a function. Unwrapped the code, problems are gone! (i wrote this because it can be helpful to developers out there.
I wanted to add a "Other" text field for comments outside the choices displayed with checboxes (like in google forms, for example). To trigger this "other" ("Altro" in the package i shared), pod creators have to write [] in the comments (eg: foo, bar, cat, []).
I was able to make the input, but, once data is filled in and the pods is saved, the data in the text field get lost. I really have no idea on how to fix this!
I hope my experience, and this helper could help someone, and i hope some could help me to improve it!
(and please someone create a podscms tag!!)
Pods 2.0 solves this kind of issue, it's now built into core as a field type option. Enjoy!

Resources