Open ifuratdev opened 5 years ago
Yes, i have to admit, this is true. In ngrest relation context, the filter won't have those context informations, as those "raw" data providers will be returned:
public function ngRestFilters() {
return [
'Online' => self::ngRestFind()->andWhere(['=', 'is_online', 1]),
'Offline' => self::ngRestFind()->andWhere(['=', 'is_online', 0]),
];
}
We would need something like:
'Online' => $this->findContext()->andWhere(...)
Thanks for the report.
i will check it and let you know
When adding ngRestFilters on a list as a result of ngRestRelations, the filter will show all rows regardless of the relationship
for example 1- in the news module, from the categories list if you select "Articles" list through the relationship for "Category
01"
2- Then from the list of news for "Category 01" if you filter on is_online using ngRestFilters, it will show all news for all categories
ngRestRelations code
public function ngRestRelations() { return [ ['label' => 'Articles', 'targetModel' => Article::class, 'dataProvider' => $this->getArticles()], ]; }
public function getArticles() { return $this->hasMany(Article::class, ['cat_id' => 'id']); }
ngRestFilters code
public function ngRestFilters() { return [ 'Online' => self::ngRestFind()->andWhere(['=', 'is_online', 1]), 'Offline' => self::ngRestFind()->andWhere(['=', 'is_online', 0]), ]; }
Image 1: News list
Image 2: Categories list
Image 3: News for Category 2 using ngRestRelations
Image 4: (The issue) News for Category 2 using ngRestRelations after using ngRestFilters