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

How to filter in GridView on parent? #115

Open
gvanto opened this issue Jan 26, 2018 · 9 comments
Open

How to filter in GridView on parent? #115

gvanto opened this issue Jan 26, 2018 · 9 comments

Comments

@gvanto
Copy link

gvanto commented Jan 26, 2018

I'm trying to filter on 'parent' of my (nested set) Category class, according to this:
http://www.yiiframework.com/wiki/621/filter-sort-by-calculated-related-fields-in-gridview-yii-2-0

But it's not working I suspect because the self-join query which would normally work on a activerecord row with 'parent_id' doesn't apply here (for nested sets).

Any ideas how to get filtering by a parent working?

Help much appreciated
Thanks

@blupointmedia
Copy link

@gvanto - did you have any luck with extending this to search on parent in GridView?

@schmunk42
Copy link
Collaborator

Just CC'ing @cebe, maybe he has an idea.

@blupointmedia
Copy link

@cebe, any thoughts?

@cebe
Copy link

cebe commented May 23, 2019

Can you provide more context and semantics?

  1. How do you fit a nested set (tree structure) into a GridView?
  2. what does "filter on parent" mean? Do you want to enter a parent ID to show all children of that parent node? all direct children or all nodes below the parent?

@blupointmedia
Copy link

Hi @cebe, I want to be able to filter gridview on category and parent category. I can do it on category since it is based on the name, but can't seem to find a way to filter on parent category name.
This solution pulls all leaves as active records, so that is how I get the categories. Currently to get the parent, I just call ->parent(1) inside of each gridview item, which I prefer to have a relation of some sort for filter and less querying.

@cebe
Copy link

cebe commented May 23, 2019

so what is llisted in your gridview? categories or items that are categorized (i.e. belong to a category)?

@gvanto
Copy link
Author

gvanto commented May 24, 2019

@gvanto - did you have any luck with extending this to search on parent in GridView?

Nope not looked into this for a while now. I am just listing a 'parent' column (but it's not yet filterable).

With filtering things in general on GridView, I have found that you need a pretty customized ActiveQuery in your backend/{Model}/Search class, so guessing a pretty complex AQ will be required here (not had time to look into building it though! )

@blupointmedia
Copy link

@cebe In the gridview right now I just have the category and then I get the parent with $model->parents(1) in a second column.

@blupointmedia
Copy link

@cebe do you have anything you can offer on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants