HELPME
HELPME

Reputation: 744

How to sort just one attribute values in yii2?

tried to check the documentation for that, but I still don't know how to do it on just one attribute.. I have:

'attribute' => 'user_id',
'label' => Module::t('app', 'USER_ID_LABEL'),
'headerOptions' => [
    'style' => 'text-align: center;'
],
'contentOptions' => [
    'style' => 'text-align: center;'
],

I need to sort that attribute values, how to do it? I checked in the documentation and tried like this:

'attribute' => [
    'user_id' => [
        'asc' => ['company_name' => SORT_ASC],
    ],
], 

But this didn't work. I need to sort the values automatically by ASC. Thank you for the help

Upvotes: 0

Views: 46

Answers (1)

Insane Skull
Insane Skull

Reputation: 9358

In your search query use :

orderBy(['company_name' => SORT_ASC])

Upvotes: 2

Related Questions