Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier way to manually apply column filters #65

Closed
techniq opened this issue Sep 19, 2012 · 3 comments
Closed

Easier way to manually apply column filters #65

techniq opened this issue Sep 19, 2012 · 3 comments

Comments

@techniq
Copy link
Contributor

techniq commented Sep 19, 2012

I have a situation where I've added a column filter to a view and would like to manually apply it in a request. For example, with the following view:

class LineItemView(ModelView):
    column_filters = [FilterEqual(models.LineItem.invoice_id, "parent")]

to apply the filter via url, I need to use something like /admin/lineitem/?flt0_0={{request.args["id"]}}, which is confusing, and reliant on knowing the index position of the filters you want to apply.

Since this is an instance filter with a name ("parent") and a specific filter (FilterEqual) instead of a genearl column name (ex. ['foo']), it would be nice if you could apply the filter like this:
/admin/lineitem/?flt_admin={{request.args["id"]}}

For the cases where just a field name is used, maybe something like:
/admin/lineitem/?flt_admin_eq={{request.args["id"]}}
/admin/lineitem/?flt_admin_ne={{request.args["id"]}}
/admin/lineitem/?flt_admin_gt={{request.args["id"]}}
/admin/lineitem/?flt_admin_lt={{request.args["id"]}}

Thoughts?

@mrjoes
Copy link
Contributor

mrjoes commented Sep 19, 2012

I see.. Current naming convention was not intended to be used outside of Flask-Admin.

While it might be OK to redo naming convention, I'm also thinking about exposing some kind of API to generate filter link based on the name and value.

@techniq
Copy link
Contributor Author

techniq commented Sep 19, 2012

I kind of figured we were using it outside of its original design :)

I think an api (something like url_for with filter awareness) would be nice. I also thinking having more expressive URLs would be nice, but understand it may not be worthwhile.

@mrjoes
Copy link
Contributor

mrjoes commented Mar 19, 2013

Closing this for now. As a workaround, you can override default filter by adding explicit filter to SQLa query.

@mrjoes mrjoes closed this as completed Mar 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants