Closed sglebs closed 1 week ago
I believe you can do the following:
When initializing the admin you define your custom view :
admin.add_view(CustomView(label="My Custom View", icon="custom_icon", path="/my_custom_view", template_path="my_custom_view.html", add_to_menu=True))
And you can all it from your custom action like this:
@row_action(
name="my_custom_action",
text="My Custom Action",
custom_response=True,
icon_class="custom_icon",
)
async def my_custom_action(self, request: Request, pks: List[Any]) -> Response:
url = "/admin/my_custom_view" # ideally we should not hardcode the path - can we get the path to a view?
return RedirectResponse(url)
ideally we should not hardcode the path - can we get the path to a view?
If you set the name attribute for your customview :
admin.add_view(CustomView(name="custom_view", ...))
you can generate the url with
request.url_for("admin:custom_view"))
this is already in the doc -> https://jowilf.github.io/starlette-admin/user-guide/actions/
Describe the bug
I have a table with records showing events. It is quite raw/basic. I would like to add an extra action button in the List View that, when clicked, takes me o a nicer view which will show me a custom historic view of related records (I have the query). It is a form of drill-down with a beautiful rendering.
I have been able to create a custom view for the home page in the past and a custom row action button that opens a dialog and executes code. But I am not suer how to make an action button take me to a custom view which is not normally available on the left menu/navigator. Any pointers?
To Reproduce
Create a custom action button which is shown in the List View and get it to open a custom view on that entity, with a custom template of yours, much like the eye or pencil icons.
Environment (please complete the following information):
Additional context I am browsing the sources to find hints.