how to search filter multipe relation table and groupping in yii2

柔情痞子 提交于 2019-12-07 21:40:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!