# Adding a dropdown to queries

**URL:** <https://community.silverbullet.md/t/adding-a-dropdown-to-queries/1122>\
**Category:** Ideas\
**Created:** [October 15, 2024, 1:59pm UTC](https://community.silverbullet.md/t/adding-a-dropdown-to-queries/1122 "2024-10-15T13:59:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bent0n](https://community.silverbullet.md/user_avatar/community.silverbullet.md/bent0n/32/604_2.png) [@bent0n](https://community.silverbullet.md/u/bent0n)\
**Post date:** [October 15, 2024, 1:59pm UTC](https://community.silverbullet.md/t/adding-a-dropdown-to-queries/1122/1 "2024-10-15T13:59:40Z")

</div>

Adding a dropdown (or multiple?) allowing to change the querry results dynamically.

For example, this would make it possible to render a table, with a dropdown to select a project status and the table would update accordingly.

````auto
```query
project
where status = dropDown(statusList)
render all [[path-to-template]] 
```

````

I’m not sure if this could be achieved with space script. But definitely above my skill level in case it is…

---

<div class="post-metadata">

**Author:** ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)\
**Post date:** [October 15, 2024, 3:14pm UTC](https://community.silverbullet.md/t/adding-a-dropdown-to-queries/1122/2 "2024-10-15T15:14:33Z")

</div>

This is definitely not reasonably possible right now. Perhaps you can do something extremely intricate with space script, but I wouldn’t recommend it.

This is an interesting use case though, and will take it into account as I explore some ideas in the Space Lua space.

Let me throw in some conceptual ideas. Not happy with them, but interested in feedback. Let’s say that we introduce the concept of a “page variable”, let’s say (although we could also just use front matter for this):

````auto
```page-vars
selected_status: "done"
```

````

And then have a way to bind a widget to it:

```auto
Select status: ${drop_down("selected_status", {"to do", "doing", "done"})}

```

Where changing that drop down, would inline update the variable value in the `page-vars` block.

Then you could have the ability to use that page variable in your query, you’d be able to get there, right?

Again, just conceptual thinking here. Not committing to anything.

---

<div class="post-metadata">

**Author:** ![Robin](https://community.silverbullet.md/user_avatar/community.silverbullet.md/robin/32/444_2.png) [@Robin](https://community.silverbullet.md/u/Robin)\
**Post date:** [October 16, 2024, 1:59am UTC](https://community.silverbullet.md/t/adding-a-dropdown-to-queries/1122/3 "2024-10-16T01:59:02Z")

</div>

Oh yes, please. If something like this turned out to be achieable i’d use it a lot.

---

<div class="post-metadata">

**Author:** ![mjf](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mjf/32/654_2.png) [@mjf](https://community.silverbullet.md/u/mjf)\
**Post date:** [October 16, 2024, 7:53am UTC](https://community.silverbullet.md/t/adding-a-dropdown-to-queries/1122/4 "2024-10-16T07:53:27Z")

</div>

**OT:** I dream of Markdown parser and document model extensibility via custom scripting…

Checklist (we have it already):

```plaintext
- [x] checked
- [] unchecked

```

Selection:

```plaintext
- ( ) unselected
- (x) selected
- (x) selected 2
- ( ) unselected

```

Colapsible lists:

```plaintext
- item 1 with colapsed sublist
  - item 1
  - item 2
+ item 2 with expanded sublist
   - item 1
   - item 2

```

And what I would love the most to have are _inline checkboxes_:

```plaintext
This is some paragraph of dummy text with a checked checkbox [x] inside
it and one more checkbox [] unchecked.

```

And, of course, everything would remember it’s state (and edit itself, as it is in case of the normal checkboxes we have).

---

<div class="post-metadata">

**Author:** ![bent0n](https://community.silverbullet.md/user_avatar/community.silverbullet.md/bent0n/32/604_2.png) [@bent0n](https://community.silverbullet.md/u/bent0n)\
**Post date:** [October 16, 2024, 8:18am UTC](https://community.silverbullet.md/t/adding-a-dropdown-to-queries/1122/5 "2024-10-16T08:18:49Z")

</div>

> [@zef](#):
>
> ````auto
> ```page-vars
> selected_status: "done"
> 
> ````
> 
> ```auto
> 
> ```

It feels unnecessary to go with a specific section for it, a subsection of the frontmatter would be more suited for it.

I was thinking more of something self contained within live query/template. However, the general workflow you describe seems well thought out. What I like about it, is that it can mostly be done already with space-script except using a push button (command link) instead of a drop down. So we’re only missing the drop down…

It seems adding the ability to create drop down menu that handles the selection of a variable and trigger a function on selection would allow lots of flexibility and is likely to bring other use cases.

---

<div class="post-metadata">

**Author:** ![justyns](https://community.silverbullet.md/user_avatar/community.silverbullet.md/justyns/32/132_2.png) [@justyns](https://community.silverbullet.md/u/justyns)\
**Post date:** [October 16, 2024, 11:44pm UTC](https://community.silverbullet.md/t/adding-a-dropdown-to-queries/1122/6 "2024-10-16T23:44:55Z")

</div>

Could schema help here? What about rendering frontmatter (or maybe other yaml code blocks too) differently to match that schema?

This isn’t currently possible, but what I’m thinking would look like this schema:

```yaml
schema:
  properties:
    status:
      type: string
      enum:
        - active
        - todo
        - completed
  required:
    - status

```

And then in frontmatter of a page:

```auto
---
status: todo
---

```

`todo` could be rendered as text by default, but if you click on it, it could turn it into a dropdown list based on the schema.

Enums would be a dropdown list and boolean a checkbox; everything else the same as it is now

---

<div class="post-metadata">

**Author:** ![bent0n](https://community.silverbullet.md/user_avatar/community.silverbullet.md/bent0n/32/604_2.png) [@bent0n](https://community.silverbullet.md/u/bent0n)\
**Post date:** [October 17, 2024, 9:51am UTC](https://community.silverbullet.md/t/adding-a-dropdown-to-queries/1122/7 "2024-10-17T09:51:46Z")

</div>

I would rather have the possibility to put the dropdown anywhere, not only in the frontmatter.

What if I have a long document with a table at the end? I don’t want to scroll back to the top to change the filtering in the frontmatter.

I would say best scenario would be next to the query buttons or in the corresponding column header.

 ![image](https://community.silverbullet.md/uploads/default/original/1X/90c366403d0a46cd0a68fd95630b6a8a4cec988d.png)

But for the sake of flexibility, something similar to the command link but generating a dropdown instead of a push button seems like a good balance.
