can Yii override sorting

RESOLVED!

Hi

I have a query that orders the results via $criteria->sort="param1 ASC"; When the application loads the respective action all is sorted…so far so good. If I however attempt to sort the results according to another attribute after the results are being displayed Yii adds another sorting parameter without removing the core declared one. So no matter how I sort afterwords all sorting becomes dependant on $criteria->sort="param1 ASC".

My question is: Is it possible to tell Yii to sort the results after they are displayed according to get parameter only and the core declared one to be used only during loading or should I extend the CSort class and add the logic myself.

Please advise.

Regards,

b

If you are using CSort,

Did you try to use CSort::defaultOrder instead of $criteria->order???

If not, try it!! :D

You can achieve that in your controller eg:




$sortBy = isset($_GET['sortBy']) ? $_GET['sortBy'] : null;

if($sortBy===null)

{

   SORT BY DEFAULT

}else{

   SORT BY GET FIELD...

}



Brilliant…looks like both solutions solved the situation. Cheers mates!