Is Drop down possible under renderdatatable

I have a simple application below. is it possible to create to dropdown for each column with column values

title: "Untitled"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
DT::dataTableOutput('a')
output$a <- DT::renderDataTable(
    iris)

What do you mean by dropdown ? A filter ?
Something like the column filtering in DT documentation ?
https://rstudio.github.io/DT/#column-filters

1 Like

Hi,

Similar like this

image

That is exactly the column filtering on DT, so cderv already gave you the solution, just read the documentation.

1 Like

I tried actually. But renderDT is not taking options as an arguments. Not sure why? Because by setting options we can enable dropdown

From the documentation given above, you'd set the filter outside of the options argument, so options is not even required:

DT::renderDataTable(iris, filter = 'top')

Ok, where is the reprex for that? how are we supposed to know what are you doing wrong if you don't show what you are doing?

Hi Sorry, the reprex was actually that I gave in the question. I tried with putting the option argument there. So did not work and therefore was not able to process reprex.

Apologies for this. Can you please provide few tips on how to produce reprex in this kind of instances. :slight_smile: Will be thankfull to you

Hi

Perfect. Actually I tried this earlier but my columns have few alpha-numeric values and only categorical values. So for that the dropdown is not working for those :frowning: . I was not sure so I was asking about options.

You have to narrow down the code to just the relevant part, in this case, it would be as simple as one line of code

# This doesn't work
DT::datatable(iris, options = list(filter = 'top'))

And the solution would be

# This works
DT::datatable(iris, filter = 'top')

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.