dosubot[bot] commented on issue #35884:
URL: https://github.com/apache/superset/issues/35884#issuecomment-3461081293
<!-- Answer -->
Here are practical examples and explanations for using native_filters,
native_filters_key, and permalink_key to preselect native filter values in
Superset dashboards (including embedded dashboards):
**1. native_filters (direct URL param, rison-encoded):**
You can pass filter values directly in the URL using the native_filters
parameter, which must be rison-encoded. The format is:
```
?native_filters=(NATIVE_FILTER-xxxx:(filterState:(value:('your_value'))))
```
For example, to preselect a filter with ID NATIVE_FILTER-b6BM3PULf to value
11, the rison-encoded string would look like:
```
?native_filters=(NATIVE_FILTER-b6BM3PULf:(filterState:(value:!(11))))
```
You can generate rison strings using online tools or libraries (e.g., npm
package rison).
[Reference](https://github.com/apache/superset/discussions/24049#discussioncomment-9643505)
**2. native_filters_key (key-based, via API):**
You can POST your desired filter state to the API endpoint:
```
POST /api/v1/dashboard/{dashboard_id}/filter_state
{
"value": "{\"NATIVE_FILTER-b6BM3PULf\":{\"filterState\":{\"value\":[11]}}}"
}
```
The response will include a key. You can then use:
```
?native_filters_key=YOUR_KEY
```
in your embedded dashboard URL or embedding config.
[Reference](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/keyValue.tsx)
**3. permalink_key (full dashboard state, via API):**
To save the entire dashboard state (including filters), POST to:
```
POST /api/v1/dashboard/{dashboard_id}/permalink
{
"state": {
"dataMask": {
"NATIVE_FILTER-b6BM3PULf": {
"filterState": {
"value": [11]
}
}
}
}
}
```
The response will include a key. Use:
```
?permalink_key=YOUR_KEY
```
to restore the dashboard with all saved state, including filters.
[Reference & example
payloads](https://github.com/apache/superset/blob/master/superset/dashboards/permalink/api.py)
**Summary of use cases:**
- Use native_filters for quick, direct filter setting via URL
(rison-encoded).
- Use native_filters_key for reusable, server-stored filter states.
- Use permalink_key for restoring a full dashboard state (filters, tabs,
etc).
For more details and examples, see the [discussion
here](https://github.com/apache/superset/discussions/24049#discussioncomment-9643505)
and the [API code
reference](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/keyValue.tsx).
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
---
<sup>How did I do?
[Good](https://app.dosu.dev/response-feedback/fa79e35b-e7a7-490c-add8-4934c74efd95?feedback_type=great_response)
|
[Irrelevant](https://app.dosu.dev/response-feedback/fa79e35b-e7a7-490c-add8-4934c74efd95?feedback_type=irrelevant_answer)
|
[Incorrect](https://app.dosu.dev/response-feedback/fa79e35b-e7a7-490c-add8-4934c74efd95?feedback_type=incorrect_sources)
|
[Verbose](https://app.dosu.dev/response-feedback/fa79e35b-e7a7-490c-add8-4934c74efd95?feedback_type=too_verbose)
|
[Hallucination](https://app.dosu.dev/response-feedback/fa79e35b-e7a7-490c-add8-4934c74efd95?feedback_type=hallucination)
| [Report
🐛](https://app.dosu.dev/response-feedback/fa79e35b-e7a7-490c-add8-4934c74efd95?feedback_type=bug_report)
|
[Other](https://app.dosu.dev/response-feedback/fa79e35b-e7a7-490c-add8-4934c74efd95?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=githu
b) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/35884)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]