问题描述
我有三个表,比如 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) 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..
解决方案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关系表和分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!