如何在yii2中搜索过滤器multipe关系表和分组 [英] how to search filter multipe relation table and groupping in yii2
问题描述
我有三个表,比如 ridersPoint(id,nameRider,serie_id,point)和
系列(serie_id,nameSerie,location,date,season_id)
和 season(season_id,nameSeason,year)
。
属性 serie_id
在 riderPoint
表中与 serie_id $ c $有关系在
系列
表中,以及在系列
中的属性 season_id
表与 season_id
在 season
表中有关系。
如何在 riderPoint
中通过 season_id
进行搜索?当数据表在同一个季节
中时如何分组点?
请帮助我。
在gridview中搜索(过滤和排序)相关的字段是一系列的行动..你可以在这个文档中找到一些示例
简介..
- 模型在(main / pivot)模型中定义您的活动关系并添加相关字段的getter
- 在您的dataProvider的modelSearch中添加var fo相关字段,设置适当的排序顺序新增相关字段,在搜索功能中添加关系,并在modelSearch条件中添加适当的过滤器。
- 将新属性添加到gridview。
在提供的链接中深入观察场景2,您可以找到wha你需要
I have three tables like
ridersPoint (id, nameRider, serie_id, point)
andseries (serie_id, nameSerie, location, date, season_id)
andseason (season_id, nameSeason, year)
. Attributeserie_id
inriderPoint
table have relation withserie_id
inseries
table, and Attributeseason_id
inseries
table have relation withseason_id
inseason
table. How to make search byseason_id
inriderPoint
? And how to groupping point when have data table in the sameseason
? Please help me..解决方案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
这篇关于如何在yii2中搜索过滤器multipe关系表和分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!