Clistview Sorter With Multiple Conditions....

Dear all,

I have a CListView Sorters like the following;


'sortableAttributes'=>array(

        'create_time'=>'Post Time',

        'money'=>'Money'

    ), 

This CListview is a list of transactions. In the transactions table, there is a column called "closed". When closed is set to 1, means the transaction is closed and I ALWAYS want the closed questions appear at the bottom of the list.

Right now, when you click sort by money, the smallest/biggest amount of money transaction will show up, even it’s closed. What I want is it sorted by “closed ASC, money DESC” or “closed ASC, money ASC” when you click the sorter “money” Is there a way to implement these multiple conditions to the sorter?

I tried to set the sort in my data provider but still does not work!


                'sort'=>array(

                    'attributes'=>array(

                         'money'=>array(

                              'asc'=>'closed ASC, money ASC',

                              'desc'=>'closed ASC, money DESC',

                          ),

                     ),

                 ),

Thanks so much for your help!!!

Hi, according to this comment the name of the virtual attribute should be different from the name of the valid attribute of that model so you should change ‘money’ (in the attributes list of sort array) to something else like money2 to avoid this conflict :)

Solved my problems. Thank you!