Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using CheckboxRelationActiveQuery and sortRelationModel can add data but not displayed on listing #257

Open
mrtrinhvn opened this issue Dec 9, 2018 · 3 comments

Comments

@mrtrinhvn
Copy link

I have model Huyet and Nhomuyet. Huyet has a property gorup_ids which store the ids of the Nhomuyet. (mean group of Huyet).
When I add a new Huyet or edit a Huyet, the window displays the checkbox with the 'ten' of Nhom huyet as expected. But when listing Huyet, Nhom huyet shown as open and close square bracket [] (if i use CheckboxRelationActiveQuery), or as [{"value":2,"label":"Block"},{"value":1,"label":"Heatting"}]. (if i use sortRelationModel).
So, how to display 'ten' of Nhomhuyet is display, more effective i can click to show the Nhomhuyet?
public function ngRestAttributeTypes()
{
return [
////using sortRelationModel
// 'group_ids' => [
// 'sortRelationModel',
// 'modelClass' => Nhomhuyet::className(),
// 'valueField' => 'id',
// 'labelField' => 'ten'
// ],
////using CheckboxRelationActiveQuery
'group_ids' => [
'class' => CheckboxRelationActiveQuery::class,
'query' => $this->getGroups(),
'labelField' => ['ten'],
],
'hinh' => 'image',
'ten' => 'text',
];
}

public function getGroups()
{
return $this->hasMany(Nhomhuyet::class, ['id' => 'nhomhuyet_id'])->viaTable(HuyetToNhom::tableName(), ['huyet_id' => 'id']);
}

@nadar
Copy link
Member

nadar commented Dec 9, 2018

Checkbox relations currently does not support list of relation data in the NgRest LIST - this is because there can be 100 of items and those:

a. slow down dramatically the list
b. unable to display 100 items which are selected.

But of course for small relation behavior, it should be able to display this data. Thanks for creating

@mrtrinhvn
Copy link
Author

Can we define or default a number max to display? I think it is better than display nothing or display json.

@nadar
Copy link
Member

nadar commented Dec 12, 2018

Maybe we could at least display the number of relation items? like a count

@nadar nadar self-assigned this Feb 26, 2019
@nadar nadar removed their assignment Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants