问题
I have three tables like ridersPoint (id, nameRider, serie_id, point)
and series (serie_id, nameSerie, location, date, season_id)
and season (season_id, nameSeason, year)
.
Attribute serie_id
in riderPoint
table have relation with serie_id
in series
table, and Attribute season_id
in series
table have relation with season_id
in season
table.
How to make search by season_id
in riderPoint
? And how to groupping point when have data table in the same season
?
Please help me..
回答1:
Search (filter and sort) for related field in gridview is base an a series of action.. you can find some sample in this doc
http://www.yiiframework.com/wiki/653/displaying-sorting-and-filtering-model-relations-on-a-gridview/
in brief..
- In your model define your active relation in (main/pivot) model and add the getter for related field
- In your modelSearch in your dataProvider add the var fo related field, set the proper sort for sorting by new related field, add the relation in search function and adding proper filter in modelSearch condition
- Add the new attribute to the gridview..
Take a deep look to the scenario 2 in the link provided.. and you can find what you need
来源:https://stackoverflow.com/questions/34916480/how-to-search-filter-multipe-relation-table-and-groupping-in-yii2