-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cascading Dropdowns #105
Comments
You could probably do this in shiny, updating the column factors on each change. It may be possible to do this via JS, but I'm not sure how that would work with the existing R code. |
Thanks @jrowen . Here is a minimal shiny app I've been playing around with, trying to do just that, pull in an updated column source on each change given the selected row. The intent of this code is to switch the source list in column B depending on the value of column A. I've got it validating if you manually enter a value from listB (at least it seems that way) but I've been unsuccessful in actually making the dropdown appear. It seems like the source for each column is called once and cached. I'm wondering if there is any way to force the reload of the source lists? EDIT: I've now been successful at making a dynamically generated dropdown appear but the problem seems to be that the source is not called on the first select of the dropdown (it will appear on the second if another row is selected before the second selection (confusing I know) see below. I know I can work on the logic below to make a non-default list appear, but that won't get around the issue with the first click.
|
The table with default to dropdown cell types if the original column in the data.frame is a factor. The dropdown choices will be the factor levels. You set the factor levels by column, so you will only be able to customize the options by column. |
Please let me know if you have additional questions. |
Could it be possible to add the type and source arguments to the hot_cell function? Now it only features readOnly and comments. Here is one JS implementation of this https://jsfiddle.net/handsoncode/1gtu29rn/. |
@Timmwardion it's been some time but, however. I'm currently working on creating row dependant dropdowns with rhandsontable and here is a workaround I came up with to prevent users from beeing able to select items which should't be available for a specific row. I'm making only those dropdowns readable, which are currently selected (via
I guess this logic can be transferred to cascading dropdowns. |
Outstanding! That does the trick. |
This is great @ismirsehregal , thanks for sharing! I noticed that for any individual row, if one fills A and B, then changes A, it is possible to have an "invalid" entry for B. (For example, in row 5, choose A=5 and B=5, then change A->4. Now you have A=4 and B=5, because B retains the original value.) How would I add functionality such that if you change A, the value in B simply deletes? |
@rliehrv you need to repeat the logic check and apply it to the Here is a modified example:
PS: Here you can find another example on SO. |
Perfect, thank you so much! |
@jeffreyxparker sorry for the late reply. I made a generalized
However, this approach requires the user to explicitly deselect their choices before all options are displayed again. |
Hey @jrowen. Firstly, thanks for the amazing package.
Secondly. I'm looking for examples of connected dropdowns using rhandsontable, where the dropdowns in column b change as column a changes. I've looked far as wide but there doesn't seem to be any examples I can find of functions in the source parameter of hot_cols or anyone using any kind of reactive function to change the source list.
The text was updated successfully, but these errors were encountered: