# 如何在 Data Explorer 中添加查询参数？

**URL:** https://meta.discourse.org/t/how-to-add-query-parameters-to-data-explorer/171260
**Category:** Development
**Created:** [2020年十一月25日 07:28 UTC](https://meta.discourse.org/t/how-to-add-query-parameters-to-data-explorer/171260 "2020-11-25T07:28:20Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [2020年十一月25日 07:28 UTC](https://meta.discourse.org/t/how-to-add-query-parameters-to-data-explorer/171260/1 "2020-11-25T07:28:21Z")

</div>

> [@Populate Data Explorer params with URL params](https://meta.discourse.org/t/populate-data-explorer-params-with-url-params/169404):
>
> It would be great if I could share a [Data Explorer](https://meta.discourse.org/t/32566?silent=true) query with a group and have the query params be pre-filled with the URL params. For example, if I have this param -- string :username, I should be able to share it with group “my-group” with username “myName”. Something like this: https://mydomain.com/g/my-group/reports/100?username=myName

我最近建议，在报表中支持查询参数会非常棒。这样，我就可以分享一个已预填默认参数的 [Data Explorer](https://meta.discourse.org/t/32566?silent=true) 链接。例如：

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/3/b3ed8e4902b56bfd64e32c7906c43b83bcbc4725.png)

有人有兴趣实现这个功能吗？

如果没有，是否有人能提供一些指导，帮助我自己实现它？

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2020年十一月25日 12:17 UTC](https://meta.discourse.org/t/how-to-add-query-parameters-to-data-explorer/171260/2 "2020-11-25T12:17:19Z")

</div>

该功能已存在。这里应该有一些您的搜索示例。

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [2020年十一月25日 12:38 UTC](https://meta.discourse.org/t/how-to-add-query-parameters-to-data-explorer/171260/3 "2020-11-25T12:38:41Z")

</div>

谢谢你的回复，Jay。

@sam 添加了 #pr-welcome 标签，所以我以为它不存在。

语法是什么？我试过 `/reports/100?username=myName`，但用户名文本框并没有填充 `myName`。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2020年十一月25日 12:46 UTC](https://meta.discourse.org/t/how-to-add-query-parameters-to-data-explorer/171260/4 "2020-11-25T12:46:32Z")

</div>

抱歉，我将报表与数据探索插件混淆了。你可以使用数据探索功能来实现该操作。

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [2020年十一月25日 12:50 UTC](https://meta.discourse.org/t/how-to-add-query-parameters-to-data-explorer/171260/5 "2020-11-25T12:50:32Z")

</div>

我尝试过 `/admin/plugins/explorer?id=100&username=myName`，但这也没有填充文本框。

我是不是漏掉了什么？

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2020年十一月25日 12:59 UTC](https://meta.discourse.org/t/how-to-add-query-parameters-to-data-explorer/171260/6 "2020-11-25T12:59:27Z")

</div>

哦，抱歉，我现在明白了。 **这正是** 我遗漏的部分。你知道如何编写查询并使用参数，但希望通过 URL 修改默认值。这也是为什么我们欢迎提交拉取请求。

为此表示歉意。

---

<div class="post-metadata">

### Author: ![Nacho\_Caballero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nacho_caballero/32/130189_2.png) [@Nacho\_Caballero](https://meta.discourse.org/u/Nacho_Caballero)
#### Post date: [2020年十一月25日 15:41 UTC](https://meta.discourse.org/t/how-to-add-query-parameters-to-data-explorer/171260/7 "2020-11-25T15:41:33Z")

</div>

没问题，我可能应该解释得更清楚些。😁

你觉得实现起来会有多难？

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2020年十一月25日 15:58 UTC](https://meta.discourse.org/t/how-to-add-query-parameters-to-data-explorer/171260/8 "2020-11-25T15:58:35Z")

</div>

不，我没读过。你表达得很清楚。

我不知道该怎么做。但既然你问了，我大胆猜测，如果有合适的规格说明，大概需要 2 到 4 个小时的工作量。
